Skip to content

Trouble Installing Pythonnet for Anaconda - Newbie #780

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Mattpdrexel opened this issue Nov 17, 2018 · 8 comments
Closed

Trouble Installing Pythonnet for Anaconda - Newbie #780

Mattpdrexel opened this issue Nov 17, 2018 · 8 comments

Comments

@Mattpdrexel
Copy link

Environment

  • Pythonnet version: 2.3.0
  • Python version: 3.7
  • Operating System: Windows 7
  • Distribution: Anaconda

Details

  • I'm attempting to install Pythonnet on my work computer via the Anaconda Prompt

    • The easy ways to download package appear to be blocked (see 1st error in post below)
    • Similar error message encountered when attempting to install using Conda (conda install -c pythonnet pythonnet).
    • SSL error messages may be related to user restrictions on my work laptop, but not sure
    • I have not found any way around this
  • Ultimately, I assume that I can only install by downloading the zip file due to my security limitations

    • I am very new to programming / python, so I have no clue how to do this
    • When I run the code listed in the wiki, I get another error message (see 2nd error in post below)
    • When I try to run pip install directly on the extracted zip file location, I get a different error message (see 3rd error in post below)

Summary of Question:
What is a simple step by step process for performing an install of Pythonnet given my restrictions?
I'm completely new to this so I'm sure I'm doing something very basic incorrectly.

If there is a better forum for this basic question, please let me know.

Thanks!

References:
https://github.com/pythonnet/pythonnet/wiki/Installation

1st Error for running pip install pythonnet - code from Anaconda command prompt:

(base) C:\Users\MATT>pip install pythonnet
Collecting pythonnet
Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None))
after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFI
CATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certif
icate (_ssl.c:1045)'))': /packages/89/3b/a22cd45b591d6cf490ee8b24d52b9db1f30b4b4
78b64a9b231c53474731e/pythonnet-2.3.0.tar.gz
Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None))
after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFI
CATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certif
icate (_ssl.c:1045)'))': /packages/89/3b/a22cd45b591d6cf490ee8b24d52b9db1f30b4b4
78b64a9b231c53474731e/pythonnet-2.3.0.tar.gz
Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None))
after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFI
CATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certif
icate (_ssl.c:1045)'))': /packages/89/3b/a22cd45b591d6cf490ee8b24d52b9db1f30b4b4
78b64a9b231c53474731e/pythonnet-2.3.0.tar.gz
Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None))
after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFI
CATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certif
icate (_ssl.c:1045)'))': /packages/89/3b/a22cd45b591d6cf490ee8b24d52b9db1f30b4b4
78b64a9b231c53474731e/pythonnet-2.3.0.tar.gz
Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None))
after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFI
CATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certif
icate (_ssl.c:1045)'))': /packages/89/3b/a22cd45b591d6cf490ee8b24d52b9db1f30b4b4
78b64a9b231c53474731e/pythonnet-2.3.0.tar.gz
Could not install packages due to an EnvironmentError: HTTPSConnectionPool(host=
'files.pythonhosted.org', port=443): Max retries exceeded with url: /packages/89
/3b/a22cd45b591d6cf490ee8b24d52b9db1f30b4b478b64a9b231c53474731e/pythonnet-2.3.0
.tar.gz (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIF
Y_FAILED] certificate verify failed: unable to get local issuer certificate (_ss
l.c:1045)')))

You are using pip version 10.0.1, however version 18.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' comm
and.

(base) C:\Users\MATT>


2nd Error for running my interpretation of instructions from wiki - code from Anaconda command prompt:

(base) C:\Users\MATT>cd C:\Users\MATT\Downloads\pythonnet-master\pythonnet-mas
ter

(base) C:\Users\MATT\Downloads\pythonnet-master\pythonnet-master>python setup.p
y bdist_wheel --xplat
running bdist_wheel
running build
running build_ext
error: [WinError 2] The system cannot find the file specified

(base) C:\Users\MATT\Downloads\pythonnet-master\pythonnet-master>


3rd Error for running pip install from downloaded zip folder - code from Anaconda command prompt:

(base) C:\Users\MATT>pip install C:\Users\MATT\Downloads\pythonnet-master\pyth
onnet-master
Processing c:\users\Matt\downloads\pythonnet-master\pythonnet-master
Building wheels for collected packages: pythonnet
Running setup.py bdist_wheel for pythonnet ... error
Complete output from command C:\Users\MATT\AppData\Local\Continuum\anaconda3
python.exe -u -c "import setuptools, tokenize;file='C:\Users\MATT\AppDat
a\Local\Temp\pip-req-build-xgqyixsc\setup.py';f=getattr(tokenize, 'open', op
en)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, _
file_, 'exec'))" bdist_wheel -d C:\Users\MATT\AppData\Local\Temp\pip-wheel-0_
g8ej3_ --python-tag cp37:
running bdist_wheel
running build
running build_ext
Checking for updates from https://www.nuget.org/api/v2/.
Currently running NuGet.exe 4.7.1.
NuGet.exe is up to date.
MSBuild auto-detection: using msbuild version '14.0' from 'C:\Program Files (x
86)\MSBuild\14.0\bin\amd64'.
All packages listed in packages.config are already installed.
Traceback (most recent call last):
File "", line 1, in
File "C:\Users\MATT\AppData\Local\Temp\pip-req-build-xgqyixsc\setup.py", li
ne 534, in
zip_safe=False,
File "C:\Users\MATT\AppData\Local\Continuum\anaconda3\lib\site-packages\set
uptools_init_.py", line 140, in setup
return distutils.core.setup(**attrs)
File "C:\Users\MATT\AppData\Local\Continuum\anaconda3\lib\distutils\core.py
", line 148, in setup
dist.run_commands()
File "C:\Users\MATT\AppData\Local\Continuum\anaconda3\lib\distutils\dist.py
", line 966, in run_commands
self.run_command(cmd)
File "C:\Users\MATT\AppData\Local\Continuum\anaconda3\lib\distutils\dist.py
", line 985, in run_command
cmd_obj.run()
File "C:\Users\MATT\AppData\Local\Temp\pip-req-build-xgqyixsc\setup.py", li
ne 482, in run
return bdist_wheel.bdist_wheel.run(self)
File "C:\Users\MATT\AppData\Local\Continuum\anaconda3\lib\site-packages\whe
el\bdist_wheel.py", line 202, in run
self.run_command('build')
File "C:\Users\MATT\AppData\Local\Continuum\anaconda3\lib\distutils\cmd.py"
, line 313, in run_command
self.distribution.run_command(command)
File "C:\Users\MATT\AppData\Local\Continuum\anaconda3\lib\distutils\dist.py
", line 985, in run_command
cmd_obj.run()
File "C:\Users\MATT\AppData\Local\Continuum\anaconda3\lib\distutils\command
\build.py", line 135, in run
self.run_command(cmd_name)
File "C:\Users\MATT\AppData\Local\Continuum\anaconda3\lib\distutils\cmd.py"
, line 313, in run_command
self.distribution.run_command(command)
File "C:\Users\MATT\AppData\Local\Continuum\anaconda3\lib\distutils\dist.py
", line 985, in run_command
cmd_obj.run()
File "C:\Users\MATT\AppData\Local\Continuum\anaconda3\lib\distutils\command
\build_ext.py", line 339, in run
self.build_extensions()
File "C:\Users\MATT\AppData\Local\Continuum\anaconda3\lib\distutils\command
\build_ext.py", line 448, in build_extensions
self._build_extensions_serial()
File "C:\Users\MATT\AppData\Local\Continuum\anaconda3\lib\distutils\command
\build_ext.py", line 473, in _build_extensions_serial
self.build_extension(ext)
File "C:\Users\MATT\AppData\Local\Temp\pip-req-build-xgqyixsc\setup.py", li
ne 257, in build_extension
manifest = self._get_manifest(dest_dir)
File "C:\Users\MATT\AppData\Local\Temp\pip-req-build-xgqyixsc\setup.py", li
ne 274, in _get_manifest
mt = self._find_msbuild_tool("mt.exe", use_windows_sdk=True)
File "C:\Users\MATT\AppData\Local\Temp\pip-req-build-xgqyixsc\setup.py", li
ne 399, in _find_msbuild_tool
raise RuntimeError("{0} could not be found".format(tool))
RuntimeError: mt.exe could not be found


Failed building wheel for pythonnet
Running setup.py clean for pythonnet
Failed to build pythonnet
twisted 18.7.0 requires PyHamcrest>=1.9.0, which is not installed.
Installing collected packages: pythonnet
Running setup.py install for pythonnet ... error
Complete output from command C:\Users\MATT\AppData\Local\Continuum\anaconda
3\python.exe -u -c "import setuptools, tokenize;file='C:\Users\MATT\AppD
ata\Local\Temp\pip-req-build-xgqyixsc\setup.py';f=getattr(tokenize, 'open',
open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code,
file, 'exec'))" install --record C:\Users\MATT\AppData\Local\Temp\pip-reco
rd-wux2fqp2\install-record.txt --single-version-externally-managed --compile:
usage: -c [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
or: -c --help [cmd1 cmd2 ...]
or: -c --help-commands
or: -c cmd --help

error: option --single-version-externally-managed not recognized

----------------------------------------

Command "C:\Users\MATT\AppData\Local\Continuum\anaconda3\python.exe -u -c "impo
rt setuptools, tokenize;file='C:\Users\MATT\AppData\Local\Temp\pip-re
q-build-xgqyixsc\setup.py';f=getattr(tokenize, 'open', open)(file);code=f.r
ead().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" ins
tall --record C:\Users\MATT\AppData\Local\Temp\pip-record-wux2fqp2\install-reco
rd.txt --single-version-externally-managed --compile" failed with error code 1 i
n C:\Users\MATT\AppData\Local\Temp\pip-req-build-xgqyixsc
You are using pip version 10.0.1, however version 18.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' comm
and.

(base) C:\Users\MATT>

@den-run-ai
Copy link
Contributor

den-run-ai commented Nov 19, 2018

@Mattpdrexel your first issue is about ssl certificate error, just upgrade pip like suggested in the error message:

https://stackoverflow.com/q/25981703/2230844

For second error you did not provide the full output from the console, hence no resolution.

For the third error the installation could not locate mt.exe on your system. What VS version do you have installed and what is the path to mt.exe on your system? We are using VS 2017 at the moment.

@Mattpdrexel
Copy link
Author

Mattpdrexel commented Nov 20, 2018

denfromufa,

Thanks for the guidance. After figuring out how to specify trusted hosts, I was able to upgrade my pip, setuptools and wheel. I also installed git through conda.

Now when I attempt to perform an install using the following command:
pip install git+https://github.com/pythonnet/pythonnet --trusted-host github.com
I get the following error messages:
Failed building wheel for pythonnet
and later
error: option --single-version-externally-managed not recognized

P.S.: I was not able to find an mt.exe file on my machine when looking in the expected folder locations:

C:\Program Files (x86)\Microsoft Visual Studio 10.0
C:\Program Files (x86)\Microsoft Visual Studio 14.0
C:\Program Files (x86)\Microsoft SDKs

I'm not sure if I have mt.exe installed on my machine at all.

See below for full error message from attempt to install using pip install git+etc.:

(base) C:\>git config --system http.sslVerify false

(base) C:\>pip install git+https://github.com/pythonnet/pythonnet --trusted-host
 github.com
Collecting git+https://github.com/pythonnet/pythonnet
  Cloning https://github.com/pythonnet/pythonnet to c:\users\pdmp0\appdata\local
\temp\pip-req-build-1foofr96
Building wheels for collected packages: pythonnet
  Running setup.py bdist_wheel for pythonnet ... error
  Complete output from command c:\users\pdmp0\appdata\local\continuum\anaconda3\
python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\PDMP0\\AppDat
a\\Local\\Temp\\pip-req-build-1foofr96\\setup.py';f=getattr(tokenize, 'open', op
en)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, _
_file__, 'exec'))" bdist_wheel -d C:\Users\PDMP0\AppData\Local\Temp\pip-wheel-jm
pwu8r7 --python-tag cp37:
  running bdist_wheel
  running build
  running build_ext
  Checking for updates from https://www.nuget.org/api/v2/.
  Currently running NuGet.exe 4.1.0.
  Updating NuGet.exe to 4.7.1.
  Update successful.
  MSBuild auto-detection: using msbuild version '14.0' from 'C:\Program Files (x
86)\MSBuild\14.0\bin\amd64'.
  Restoring NuGet package NUnit.ConsoleRunner.3.7.0.
  Restoring NuGet package NUnit.3.7.1.
  Restoring NuGet package UnmanagedExports.1.2.7.
  Adding package 'NUnit.ConsoleRunner.3.7.0' to folder 'C:\Users\PDMP0\AppData\L
ocal\Temp\pip-req-build-1foofr96\packages'
  Adding package 'UnmanagedExports.1.2.7' to folder 'C:\Users\PDMP0\AppData\Loca
l\Temp\pip-req-build-1foofr96\packages'
  Adding package 'NUnit.3.7.1' to folder 'C:\Users\PDMP0\AppData\Local\Temp\pip-
req-build-1foofr96\packages'
  Added package 'UnmanagedExports.1.2.7' to folder 'C:\Users\PDMP0\AppData\Local
\Temp\pip-req-build-1foofr96\packages'
  Added package 'NUnit.ConsoleRunner.3.7.0' to folder 'C:\Users\PDMP0\AppData\Lo
cal\Temp\pip-req-build-1foofr96\packages'
  Added package 'NUnit.3.7.1' to folder 'C:\Users\PDMP0\AppData\Local\Temp\pip-r
eq-build-1foofr96\packages'

  NuGet Config files used:
      C:\Users\PDMP0\AppData\Local\Temp\pip-req-build-1foofr96\NuGet.Config
      C:\Users\PDMP0\AppData\Roaming\NuGet\NuGet.Config

  Feeds used:
      C:\Users\PDMP0\.nuget\packages\
      https://dotnet.myget.org/F/dotnet-core/api/v3/index.json
      https://api.nuget.org/v3/index.json

  Installed:
      3 package(s) to packages.config projects
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "C:\Users\PDMP0\AppData\Local\Temp\pip-req-build-1foofr96\setup.py", li
ne 534, in <module>
      zip_safe=False,
    File "c:\users\pdmp0\appdata\local\continuum\anaconda3\lib\site-packages\set
uptools\__init__.py", line 143, in setup
      return distutils.core.setup(**attrs)
    File "c:\users\pdmp0\appdata\local\continuum\anaconda3\lib\distutils\core.py
", line 148, in setup
      dist.run_commands()
    File "c:\users\pdmp0\appdata\local\continuum\anaconda3\lib\distutils\dist.py
", line 966, in run_commands
      self.run_command(cmd)
    File "c:\users\pdmp0\appdata\local\continuum\anaconda3\lib\distutils\dist.py
", line 985, in run_command
      cmd_obj.run()
    File "C:\Users\PDMP0\AppData\Local\Temp\pip-req-build-1foofr96\setup.py", li
ne 482, in run
      return bdist_wheel.bdist_wheel.run(self)
    File "c:\users\pdmp0\appdata\local\continuum\anaconda3\lib\site-packages\whe
el\bdist_wheel.py", line 188, in run
      self.run_command('build')
    File "c:\users\pdmp0\appdata\local\continuum\anaconda3\lib\distutils\cmd.py"
, line 313, in run_command
      self.distribution.run_command(command)
    File "c:\users\pdmp0\appdata\local\continuum\anaconda3\lib\distutils\dist.py
", line 985, in run_command
      cmd_obj.run()
    File "c:\users\pdmp0\appdata\local\continuum\anaconda3\lib\distutils\command
\build.py", line 135, in run
      self.run_command(cmd_name)
    File "c:\users\pdmp0\appdata\local\continuum\anaconda3\lib\distutils\cmd.py"
, line 313, in run_command
      self.distribution.run_command(command)
    File "c:\users\pdmp0\appdata\local\continuum\anaconda3\lib\distutils\dist.py
", line 985, in run_command
      cmd_obj.run()
    File "c:\users\pdmp0\appdata\local\continuum\anaconda3\lib\distutils\command
\build_ext.py", line 339, in run
      self.build_extensions()
    File "c:\users\pdmp0\appdata\local\continuum\anaconda3\lib\distutils\command
\build_ext.py", line 448, in build_extensions
      self._build_extensions_serial()
    File "c:\users\pdmp0\appdata\local\continuum\anaconda3\lib\distutils\command
\build_ext.py", line 473, in _build_extensions_serial
      self.build_extension(ext)
    File "C:\Users\PDMP0\AppData\Local\Temp\pip-req-build-1foofr96\setup.py", li
ne 257, in build_extension
      manifest = self._get_manifest(dest_dir)
    File "C:\Users\PDMP0\AppData\Local\Temp\pip-req-build-1foofr96\setup.py", li
ne 274, in _get_manifest
      mt = self._find_msbuild_tool("mt.exe", use_windows_sdk=True)
    File "C:\Users\PDMP0\AppData\Local\Temp\pip-req-build-1foofr96\setup.py", li
ne 399, in _find_msbuild_tool
      raise RuntimeError("{0} could not be found".format(tool))
  RuntimeError: mt.exe could not be found

  ----------------------------------------
  Failed building wheel for pythonnet
  Running setup.py clean for pythonnet
Failed to build pythonnet
Installing collected packages: pythonnet
  Running setup.py install for pythonnet ... error
    Complete output from command c:\users\pdmp0\appdata\local\continuum\anaconda
3\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\PDMP0\\AppD
ata\\Local\\Temp\\pip-req-build-1foofr96\\setup.py';f=getattr(tokenize, 'open',
open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code,
 __file__, 'exec'))" install --record C:\Users\PDMP0\AppData\Local\Temp\pip-reco
rd-0smk2w6g\install-record.txt --single-version-externally-managed --compile:
    usage: -c [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
       or: -c --help [cmd1 cmd2 ...]
       or: -c --help-commands
       or: -c cmd --help

    error: option --single-version-externally-managed not recognized

    ----------------------------------------
Command "c:\users\pdmp0\appdata\local\continuum\anaconda3\python.exe -u -c "impo
rt setuptools, tokenize;__file__='C:\\Users\\PDMP0\\AppData\\Local\\Temp\\pip-re
q-build-1foofr96\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.r
ead().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" ins
tall --record C:\Users\PDMP0\AppData\Local\Temp\pip-record-0smk2w6g\install-reco
rd.txt --single-version-externally-managed --compile" failed with error code 1 i
n C:\Users\PDMP0\AppData\Local\Temp\pip-req-build-1foofr96\

(base) C:\>

@den-run-ai
Copy link
Contributor

den-run-ai commented Nov 20, 2018

just grab the wheels from appveyor artifacts for master branch. you cannot build from source without mt.exe - it comes with the MSVC or WinSDK:

https://docs.microsoft.com/en-us/windows/desktop/sbscs/mt-exe

The second error error: option --single-version-externally-managed not recognized can be avoid by building using setup.py. It is tracked here:

#731

@den-run-ai
Copy link
Contributor

new users should just do pip install pythonnet

@Mattpdrexel
Copy link
Author

denfromufa,

Thanks for the additional response. I think I'll need to get a recent version of Windows SDK installed on my machine in order to get mt.exe. I'll pursue this now.

In the meantime, I am not familiar with appveyor artifacts (what they are or how to use them). I'll need to look into this, but I feel like this may be too advanced for my current skill set.

Thanks for the help.

@den-run-ai
Copy link
Contributor

den-run-ai commented Nov 20, 2018 via email

@den-run-ai
Copy link
Contributor

den-run-ai commented Nov 21, 2018

You can get unofficial pythonnet for python 3.7 also here:

https://www.lfd.uci.edu/~gohlke/pythonlibs/#pythonnet

or grab the wheels from appveyor artifacts for master branch

@Mattpdrexel
Copy link
Author

denfromufa,

Looks like the unoffical install worked without a problem using pip install!

Thanks for all the help!
I'll eventually determine how to perform the official install once I identify issue with the mt.exe file location, but this works great for now.

Thank you so much for all the help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants