I'm trying to install pythonnet on my mac. I have pretty much the same issue as #269, I even tried the solutions suggested there but they didn't work.
I ran the Pypi installation command in my terminal
pip install pythonnet
This is the output for the command:
```Collecting pythonnet
Using cached pythonnet-2.3.0.tar.gz
Building wheels for collected packages: pythonnet
Running setup.py bdist_wheel for pythonnet ... error
Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/x8/j3mhghcd7nxc9y88z64czp1r0000gp/T/pip-build-4ndxpN/pythonnet/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('rn', 'n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /var/folders/x8/j3mhghcd7nxc9y88z64czp1r0000gp/T/tmpN575Xspip-wheel- --python-tag cp27:
running bdist_wheel
running build
running build_ext
Checking for updates from https://www.nuget.org/api/v2/.
Currently running NuGet.exe 3.5.0.
Updating NuGet.exe to 4.3.0.
Update successful.
MSBuild auto-detection: using msbuild version '15.0' from '/Library/Frameworks/Mono.framework/Versions/Current/lib/mono/msbuild/15.0/bin/'.
Restoring NuGet package NUnit.ConsoleRunner.3.6.0.
Restoring NuGet package UnmanagedExports.1.2.7.
Restoring NuGet package NUnit.3.6.0.
Adding package 'NUnit.3.6.0' to folder '/private/var/folders/x8/j3mhghcd7nxc9y88z64czp1r0000gp/T/pip-build-4ndxpN/pythonnet/packages'
Adding package 'UnmanagedExports.1.2.7' to folder '/private/var/folders/x8/j3mhghcd7nxc9y88z64czp1r0000gp/T/pip-build-4ndxpN/pythonnet/packages'
Adding package 'NUnit.ConsoleRunner.3.6.0' to folder '/private/var/folders/x8/j3mhghcd7nxc9y88z64czp1r0000gp/T/pip-build-4ndxpN/pythonnet/packages'
Added package 'UnmanagedExports.1.2.7' to folder '/private/var/folders/x8/j3mhghcd7nxc9y88z64czp1r0000gp/T/pip-build-4ndxpN/pythonnet/packages'
Added package 'NUnit.ConsoleRunner.3.6.0' to folder '/private/var/folders/x8/j3mhghcd7nxc9y88z64czp1r0000gp/T/pip-build-4ndxpN/pythonnet/packages'
Added package 'NUnit.3.6.0' to folder '/private/var/folders/x8/j3mhghcd7nxc9y88z64czp1r0000gp/T/pip-build-4ndxpN/pythonnet/packages'
NuGet Config files used:
/Users/Daan/.config/NuGet/NuGet.Config
Feeds used:
/Users/Daan/.nuget/packages/
https://api.nuget.org/v3/index.json
Installed:
3 package(s) to packages.config projects
xbuild tool is deprecated and will be removed in future updates, use msbuild instead <<<<
XBuild Engine Version 14.0
Mono, Version 5.4.0.0
Copyright (C) 2005-2013 Various Mono authors
xbuild tool is deprecated and will be removed in future updates, use msbuild instead <<<<
XBuild Engine Version 14.0
Mono, Version 5.4.0.0
Copyright (C) 2005-2013 Various Mono authors
Configuration: ReleaseMono Platform: x64
/private/var/folders/x8/j3mhghcd7nxc9y88z64czp1r0000gp/T/pip-build-4ndxpN/pythonnet/src/runtime/Python.Runtime.csproj: error : Error executing task Copy: Error converting Property named 'SourceFiles' with value '$(TargetAssemblyPdb)' to type Microsoft.Build.Framework.ITaskItem[]: Can't concatenate Item list with other strings where an item list is expected ('@(_OutDirItem->'%(FullPath)')', 'Python.Runtime.pdb'). Use semi colon to separate items.
Traceback (most recent call last):
File "
File "/private/var/folders/x8/j3mhghcd7nxc9y88z64czp1r0000gp/T/pip-build-4ndxpN/pythonnet/setup.py", line 405, in
zip_safe=False,
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py", line 151, in setup
dist.run_commands()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 953, in run_commands
self.run_command(cmd)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/Library/Python/2.7/site-packages/wheel/bdist_wheel.py", line 179, in run
self.run_command('build')
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/cmd.py", line 326, in run_command
self.distribution.run_command(command)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/command/build.py", line 127, in run
self.run_command(cmd_name)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/cmd.py", line 326, in run_command
self.distribution.run_command(command)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/command/build_ext.py", line 337, in run
self.build_extensions()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/command/build_ext.py", line 446, in build_extensions
self.build_extension(ext)
File "/private/var/folders/x8/j3mhghcd7nxc9y88z64czp1r0000gp/T/pip-build-4ndxpN/pythonnet/setup.py", line 222, in build_extension
subprocess.check_call(" ".join(cmd + ["/t:Build"]), shell=use_shell)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 540, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command 'xbuild pythonnet.sln /p:Configuration=ReleaseMono /p:Platform=x64 /p:DefineConstants="PYTHON27,PYTHON2,UCS2,MONO_OSX,PYTHON_WITHOUT_ENABLE_SHARED" /p:PythonBuildDir="/private/var/folders/x8/j3mhghcd7nxc9y88z64czp1r0000gp/T/pip-build-4ndxpN/pythonnet/build/lib.macosx-10.12-intel-2.7" /p:PythonInteropFile="interop27.cs" /verbosity:minimal /t:Build' returned non-zero exit status 1
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 /usr/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/x8/j3mhghcd7nxc9y88z64czp1r0000gp/T/pip-build-4ndxpN/pythonnet/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('rn', 'n');f.close();exec(compile(code, __file__, 'exec'))" install --record /var/folders/x8/j3mhghcd7nxc9y88z64czp1r0000gp/T/pip-s90sjL-record/install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_ext
Checking for updates from https://www.nuget.org/api/v2/.
Currently running NuGet.exe 4.3.0.
NuGet.exe is up to date.
MSBuild auto-detection: using msbuild version '15.0' from '/Library/Frameworks/Mono.framework/Versions/Current/lib/mono/msbuild/15.0/bin/'.
All packages listed in packages.config are already installed.
>>>> xbuild tool is deprecated and will be removed in future updates, use msbuild instead <<<<
XBuild Engine Version 14.0
Mono, Version 5.4.0.0
Copyright (C) 2005-2013 Various Mono authors
>>>> xbuild tool is deprecated and will be removed in future updates, use msbuild instead <<<<
XBuild Engine Version 14.0
Mono, Version 5.4.0.0
Copyright (C) 2005-2013 Various Mono authors
Configuration: ReleaseMono Platform: x64
/private/var/folders/x8/j3mhghcd7nxc9y88z64czp1r0000gp/T/pip-build-4ndxpN/pythonnet/src/runtime/Python.Runtime.csproj: error : Error executing task Copy: Error converting Property named 'SourceFiles' with value '$(TargetAssemblyPdb)' to type Microsoft.Build.Framework.ITaskItem[]: Can't concatenate Item list with other strings where an item list is expected ('@(_OutDirItem->'%(FullPath)')', 'Python.Runtime.pdb'). Use semi colon to separate items.
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/x8/j3mhghcd7nxc9y88z64czp1r0000gp/T/pip-build-4ndxpN/pythonnet/setup.py", line 405, in <module>
zip_safe=False,
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py", line 151, in setup
dist.run_commands()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 953, in run_commands
self.run_command(cmd)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/setuptools/command/install.py", line 61, in run
return orig.install.run(self)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/command/install.py", line 573, in run
self.run_command('build')
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/cmd.py", line 326, in run_command
self.distribution.run_command(command)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/command/build.py", line 127, in run
self.run_command(cmd_name)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/cmd.py", line 326, in run_command
self.distribution.run_command(command)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/command/build_ext.py", line 337, in run
self.build_extensions()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/command/build_ext.py", line 446, in build_extensions
self.build_extension(ext)
File "/private/var/folders/x8/j3mhghcd7nxc9y88z64czp1r0000gp/T/pip-build-4ndxpN/pythonnet/setup.py", line 222, in build_extension
subprocess.check_call(" ".join(cmd + ["/t:Build"]), shell=use_shell)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 540, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command 'xbuild pythonnet.sln /p:Configuration=ReleaseMono /p:Platform=x64 /p:DefineConstants="PYTHON27,PYTHON2,UCS2,MONO_OSX,PYTHON_WITHOUT_ENABLE_SHARED" /p:PythonBuildDir="/private/var/folders/x8/j3mhghcd7nxc9y88z64czp1r0000gp/T/pip-build-4ndxpN/pythonnet/build/lib.macosx-10.12-intel-2.7" /p:PythonInteropFile="interop27.cs" /verbosity:minimal /t:Build' returned non-zero exit status 1
----------------------------------------
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/x8/j3mhghcd7nxc9y88z64czp1r0000gp/T/pip-build-4ndxpN/pythonnet/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('rn', 'n');f.close();exec(compile(code, __file__, 'exec'))" install --record /var/folders/x8/j3mhghcd7nxc9y88z64czp1r0000gp/T/pip-s90sjL-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/x8/j3mhghcd7nxc9y88z64czp1r0000gp/T/pip-build-4ndxpN/pythonnet/
- And running the command
/usr/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/x8/j3mhghcd7nxc9y88z64czp1r0000gp/T/pip-build-4ndxpN/pythonnet/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('rn', 'n');f.close();exec(compile(code, __file__, 'exec'))" install --record /var/folders/x8/j3mhghcd7nxc9y88z64czp1r0000gp/T/pip-s90sjL-record/install-record.txt --single-version-externally-managed --compile
gets me
Traceback (most recent call last):
File "
IOError: [Errno 2] No such file or directory: '/private/var/folders/x8/j3mhghcd7nxc9y88z64czp1r0000gp/T/pip-build-4ndxpN/pythonnet/setup.py'
```
please follow instruction for mac here:
https://github.com/pythonnet/pythonnet/issues/465
You probably need to install from master branch:
I tried installing from master but I got the same error:
Collecting git+https://github.com/pythonnet/pythonnet
Cloning https://github.com/pythonnet/pythonnet to /private/var/folders/x8/j3mhghcd7nxc9y88z64czp1r0000gp/T/pip-x_bOjR-build
Installing collected packages: pythonnet
Running setup.py install for pythonnet ... error
Complete output from command /Users/Daan/anaconda2/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/x8/j3mhghcd7nxc9y88z64czp1r0000gp/T/pip-x_bOjR-build/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /var/folders/x8/j3mhghcd7nxc9y88z64czp1r0000gp/T/pip-2i8JyC-record/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 "/Users/Daan/anaconda2/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/x8/j3mhghcd7nxc9y88z64czp1r0000gp/T/pip-x_bOjR-build/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /var/folders/x8/j3mhghcd7nxc9y88z64czp1r0000gp/T/pip-2i8JyC-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/x8/j3mhghcd7nxc9y88z64czp1r0000gp/T/pip-x_bOjR-build/
As for following the instructions in #465, which python points to the anaconda libraries but I can't find clr.so
This is generic python problem. Try to follow this like threads https://stackoverflow.com/questions/14296531/what-does-error-option-single-version-externally-managed-not-recognized-ind
pip install pip --upgrade
pip install setuptools --upgrade
Should solve this issue
We try to install pythonnet on Linux and upgrading pip and setuptools does not help:
$ pip install --upgrade pip setuptools
Downloading/unpacking pip from https://pypi.python.org/packages/b6/ac/7015eb97dc749283ffdec1c3a88ddb8ae03b8fad0f0e611408f196358da3/pip-9.0.1-py2.py3-none-any.whl#md5=297dbd16ef53bcef0447d245815f5144
Downloading/unpacking setuptools from https://pypi.python.org/packages/bd/4c/b06ab3abfc8bc93b87b70f4cab22352c3c72deba7b71390d14bfffa97c85/setuptools-36.6.0-py2.py3-none-any.whl#md5=df531523e300bc3e6b9ce4451681912c
Installing collected packages: pip, setuptools
Found existing installation: pip 1.5.4
Not uninstalling pip at /usr/lib/python2.7/dist-packages, owned by OS
Found existing installation: setuptools 3.3
Not uninstalling setuptools at /usr/lib/python2.7/dist-packages, owned by OS
Successfully installed pip setuptools
Cleaning up...
$ python --version
Python 2.7.6
$ pip --version
pip 9.0.1 from /usr/local/lib/python2.7/dist-packages (python 2.7)
$ pip show setuptools
Name: setuptools
Version: 36.6.0
Summary: Easily download, build, install, upgrade, and uninstall Python packages
Home-page: https://github.com/pypa/setuptools
Author: Python Packaging Authority
Author-email: [email protected]
License: UNKNOWN
Location: /usr/local/lib/python2.7/dist-packages
Requires:
$ pip install git+https://github.com/pythonnet/pythonnet
Collecting git+https://github.com/pythonnet/pythonnet
Cloning https://github.com/pythonnet/pythonnet to /tmp/pip-zf7XdG-build
Installing collected packages: pythonnet
Running setup.py install for pythonnet: started
Running setup.py install for pythonnet: finished with status 'error'
Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-zf7XdG-build/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-aX1bur-record/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 "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-zf7XdG-build/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-aX1bur-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-zf7XdG-build/
What helped was another hint that we found in the thread @dmitriyse already mentioned: using --egg:
$ pip install --egg git+https://github.com/pythonnet/pythonnet
DEPRECATION: --egg has been deprecated and will be removed in the future. This flag is mutually exclusive with large parts of pip, and actually using it invalidates pip's ability to manage the installation process.
Collecting git+https://github.com/pythonnet/pythonnet
Cloning https://github.com/pythonnet/pythonnet to /tmp/pip-EEz_4K-build
Installing collected packages: pythonnet
Running setup.py install for pythonnet ... done
Successfully installed pythonnet-2.4.0.dev0
However, the --egg option is deprecated.
@hjaekel we are tracking this pip+git error in another issue: https://github.com/pythonnet/pythonnet/issues/555
Thanks for your efforts @hjaekel and @CodeProQuo, please don't forget to star this project! :+1:
pip install pip --upgrade pip install setuptools --upgradeShould solve this issue
This completely broke my setup:
ImportError: cannot import name main
@phxn please read this thread below and this has nothing to do with pythonnet. But in general I agree that users should work in virtual environment, rather than messing with system python installation:
Another way to resolve this is to download Windows SDK 10 (latest version). If this alone doesn't work then download Visual Studio 2019 (again whichever is the latest version). This updates the wheel process.
Try downloading the wheel file from https://pypi.org/project/pythonnet/#modal-close pythonnet downloads. Make sure you download the correct version and use pip install
pip install pip --upgrade pip install setuptools --upgradeShould solve this issue
I wanted to install a venv for python3.8.2 and Building wheel for pandocfilters and others prdouced erros. Executing your steps and building the venv again solved my issue.
Most helpful comment
Should solve this issue