Repository navigation
Add to docs a setup steps for Linux #241
Copy link
Copy link
Closed
Description
Hello, I was trying to setup PythonNet on my Linux machine and it was not easy for me. I have the next issue:
root@azh:~/Downloads/pythonnet-2.1.0# pip3 install pythonnet
The directory '/home/azh/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/azh/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting pythonnet
Downloading pythonnet-2.1.0.zip (841kB)
100% |████████████████████████████████| 849kB 1.2MB/s
Installing collected packages: pythonnet
Running setup.py install for pythonnet ... error
Complete output from command /usr/bin/python3.5 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-ropnhfme/pythonnet/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-j69ui9dw-record/install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_ext
Installing 'UnmanagedExports 1.2.6'.
Installing 'NUnit 2.6.2'.
Successfully installed 'NUnit 2.6.2'.
Successfully installed 'UnmanagedExports 1.2.6'.
/usr/bin/python3.5: can't open file 'tools/geninterop/geninterop.py': [Errno 2] No such file or directory
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-ropnhfme/pythonnet/setup.py", line 357, in <module>
setup_requires=setup_requires
File "/usr/lib/python3.5/distutils/core.py", line 148, in setup
dist.run_commands()
File "/usr/lib/python3.5/distutils/dist.py", line 955, in run_commands
self.run_command(cmd)
File "/usr/lib/python3.5/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/usr/local/lib/python3.5/dist-packages/setuptools/command/install.py", line 61, in run
return orig.install.run(self)
File "/usr/lib/python3.5/distutils/command/install.py", line 583, in run
self.run_command('build')
File "/usr/lib/python3.5/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/usr/lib/python3.5/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/usr/lib/python3.5/distutils/command/build.py", line 135, in run
self.run_command(cmd_name)
File "/usr/lib/python3.5/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/usr/lib/python3.5/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/usr/lib/python3.5/distutils/command/build_ext.py", line 338, in run
self.build_extensions()
File "/usr/lib/python3.5/distutils/command/build_ext.py", line 447, in build_extensions
self._build_extensions_serial()
File "/usr/lib/python3.5/distutils/command/build_ext.py", line 472, in _build_extensions_serial
self.build_extension(ext)
File "/tmp/pip-build-ropnhfme/pythonnet/setup.py", line 168, in build_extension
_check_output([sys.executable, geninterop, interop_file])
File "/tmp/pip-build-ropnhfme/pythonnet/setup.py", line 283, in _check_output
raise CalledProcessError(retcode, cmd, output=output)
subprocess.CalledProcessError: Command '['/usr/bin/python3.5', 'tools/geninterop/geninterop.py', 'src/runtime/interop35m.cs']' returned non-zero exit status 2
----------------------------------------
Command "/usr/bin/python3.5 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-ropnhfme/pythonnet/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-j69ui9dw-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-ropnhfme/pythonnet/
root@azh:~/Downloads/pythonnet-2.1.0# exit
exit
azh@azh:~/Downloads/pythonnet-2.1.0$
azh@azh:~/Downloads/pythonnet-2.1.0$ pip install pythonnet
Collecting pythonnet
Downloading pythonnet-2.1.0.zip (841kB)
100% |████████████████████████████████| 849kB 1.1MB/s
Installing collected packages: pythonnet
Running setup.py install for pythonnet ... error
Complete output from command /usr/bin/python3.5 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-jv9oykad/pythonnet/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-tshgkshh-record/install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_ext
Installing 'UnmanagedExports 1.2.6'.
Installing 'NUnit 2.6.2'.
Could not find a part of the path "/tmp/nuget/2bi76z0q.44m/license.txt".
Could not find a part of the path "/tmp/nuget/58q8hn2f.z9m/lib/net/RGiesecke.DllExport.Metadata.dll".
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-jv9oykad/pythonnet/setup.py", line 357, in <module>
setup_requires=setup_requires
File "/usr/lib/python3.5/distutils/core.py", line 148, in setup
dist.run_commands()
File "/usr/lib/python3.5/distutils/dist.py", line 955, in run_commands
self.run_command(cmd)
File "/usr/lib/python3.5/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/usr/local/lib/python3.5/dist-packages/setuptools/command/install.py", line 61, in run
return orig.install.run(self)
File "/usr/lib/python3.5/distutils/command/install.py", line 583, in run
self.run_command('build')
File "/usr/lib/python3.5/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/usr/lib/python3.5/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/usr/lib/python3.5/distutils/command/build.py", line 135, in run
self.run_command(cmd_name)
File "/usr/lib/python3.5/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/usr/lib/python3.5/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/usr/lib/python3.5/distutils/command/build_ext.py", line 338, in run
self.build_extensions()
File "/usr/lib/python3.5/distutils/command/build_ext.py", line 447, in build_extensions
self._build_extensions_serial()
File "/usr/lib/python3.5/distutils/command/build_ext.py", line 472, in _build_extensions_serial
self.build_extension(ext)
File "/tmp/pip-build-jv9oykad/pythonnet/setup.py", line 122, in build_extension
self._install_packages()
File "/tmp/pip-build-jv9oykad/pythonnet/setup.py", line 231, in _install_packages
check_call(cmd, shell=use_shell)
File "/usr/lib/python3.5/subprocess.py", line 581, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command 'mono tools/nuget/nuget.exe restore pythonnet.sln -o packages' returned non-zero exit status 1
----------------------------------------
Command "/usr/bin/python3.5 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-jv9oykad/pythonnet/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-tshgkshh-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-jv9oykad/pythonnet/
Metadata
Metadata
Assignees
Labels
No labels
Activity
den-run-ai commentedon Jul 19, 2016
In your case
geninterop.pyfailed most likely because you aremissing pycparser, ply, or clang (in your path). We are not bundling
pre-generated interop35m.cs for Mono to be used in setup.py because
your python is build with a special abiflag --with-pymalloc (flag: m )
On Tue, Jul 19, 2016 at 8:33 AM, ZhukovGreen [email protected]
wrote:
tonyroberts commentedon Jul 19, 2016
This looks like at least one of the problems:
/usr/bin/python3.5: can't open file 'tools/geninterop/geninterop.py': [Errno 2] No such file or directory
Perhaps there's a packaging issue where the wheel doesn't contain the tools...
You could try cloning the source from github and building from that instead ("python setup.py build")
Looks like there is also a problem with nuget. You should check the steps in the .travis.yml file and make sure you have done everything in there. It might be something like the certificates not having been installed.
den-run-ai commentedon Jul 19, 2016
@tonyroberts thanks for correcting me! Indeed I just downloaded the source
archive pythonnet-2.1.0 from PYPI and it does NOT bundle geninterop.py,
although nuget.exe is provided.
https://pypi.python.org/packages/b3/06/df4041021d83931ec3d963e782a05d115e99a0dd266cbedf408bda8840d5/pythonnet-2.1.0.zip#md5=4d4ca2ec11dc5e31c9aa142ed5f84a8e
On Tue, Jul 19, 2016 at 9:47 AM, Tony Roberts [email protected]
wrote:
den-run-ai commentedon Jul 19, 2016
perhaps we could also provide manylinux wheels:
https://github.com/pypa/manylinux
zhukovgreen commentedon Aug 3, 2016
Thank you for help, I tried to manually install it from the latest release. The output is the following:
Please advise
den-run-ai commentedon Aug 3, 2016
Here is the list of pre-requisites for installation on Linux:
https://github.com/pythonnet/pythonnet/blob/master/.travis.yml
and here is how typical build looks like on Travis CI for Linux:
https://travis-ci.org/pythonnet/pythonnet/jobs/148513880
den-run-ai commentedon Aug 3, 2016
btw, with git and pip you can just do this command after installing dependencies. No need to manually download the source code.
pip install git+https://github.com/pythonnet/pythonnetzhukovgreen commentedon Aug 3, 2016
Hello,
I did everything in according with instruction. First thing I was needed to add was:
sudo apt install libglib2.0-devwithout it I had an error during installation.Another problem (the most mysterious one) is after running a test file:
I tried to reinstall completely mono, but no changes.
Any idea?
zhukovgreen commentedon Aug 3, 2016
Might be helpful. I have installed IronPython and it works with the same Mono
den-run-ai commentedon Aug 3, 2016
IronPython is not using C-API for Mono and CPython, so no need to compare it here. Please report your Linux version, Mono runtime, CPython version and how it was installed or built.
if you can record your full installation session using https://asciinema.org that would be great!
den-run-ai commentedon Aug 3, 2016
looks like you are hitting a bug in Mono, which was fixed in 4.3.2:
https://bugzilla.xamarin.com/show_bug.cgi?id=30594
zhukovgreen commentedon Aug 9, 2016
Hello,
this is a recording of my session: https://asciinema.org/a/8aqpv14cq6ymnwkknltgcvet2
Linux is 4.4.0-31-generic, Mono - 4.4.2.11/f72fe45 Fri Jul 29 09:58:49 UTC 2016.
CPython - I don't know.
den-run-ai commentedon Aug 9, 2016
@zhukovgreen you forgot
python setup.py build_ext --inplace. also your stack trace is visible only partially at the end of the recording.zhukovgreen commentedon Aug 9, 2016
OK, thanks for that. Now it is corrected:
http://asciinema.org/a/6epq9tsvpwgjrc96gavjxkcle
den-run-ai commentedon Aug 9, 2016
@zhukovgreen I cannot believe that we are hitting so many bugs with Mono:
tjanczuk/edge#446
try Mono 4.2.4 like suggested in this linked issue.
den-run-ai commentedon Aug 9, 2016
mono 4.2.4.4 - this is what we are using in the travis build, please repeat all steps including dependencies. why did you switch to mono 4.4.2.0?
zhukovgreen commentedon Aug 9, 2016
I have tried mono 4.2.4.4 and the issue was persist with the same error. After that I switched to ironpython and reinstall the mono to the most recent version
zhukovgreen commentedon Aug 9, 2016
The comment #241 (comment)
shows my screen when I had mono 4.2.4.4
zhukovgreen commentedon Aug 9, 2016
I will share a asciinema recording a bit later
den-run-ai commentedon Aug 11, 2016
@zhukovgreen did pythonnet work for you finally? if not, then please send asciinema recording by repeating all steps in Travis CI.
Also report your Linux Distro (Ubuntu, Debian etc.)
zhukovgreen commentedon Aug 12, 2016
Hello @denfromufa,
I can't go further the command:
it says:
I completely purged all mono files, removed repository and replaced it with the 4.2.4 snapshot repo.
apt autoremoveorapt install -fnot helping.Anyway since it lasting too long, I suggest to close the issue, hoping that it is only unique not repetitive bug related to some specifics of my PC.
Thank you for your time
den-run-ai commentedon Aug 19, 2016
@zhukovgreen I think you need to report your problem with mono installation here:
https://bugzilla.xamarin.com/enter_bug.cgi?classification=__all
This has nothing to do with pythonnet.
den-run-ai commentedon Aug 19, 2016
Also you may need to update your list of available packages like this:
sudo apt-get updateden-run-ai commentedon Sep 20, 2016
@zhukovgreen FYI in version 2.2.0-dev1 we are bundling geninterop.py now.
pip install pythonnet --pre
laskeym commentedon Jul 5, 2017
Hello. I'm trying to install pythonnet on Ubuntu 12.04 running Python 2.7.3. I've followed the build from https://travis-ci.org/pythonnet/pythonnet/jobs/148513880 and ran
sudo python setup.py build_ext --inplaceand the following was the output:sudo python setup.py build_ext --inplacerunning build_ext
Checking for updates from https://www.nuget.org/api/v2/.
Currently running NuGet.exe 4.1.0.
NuGet.exe is up to date.
MSBuild auto-detection: using msbuild version '14.0' from '/usr/lib/mono/xbuild/14.0/bin'.
All packages listed in packages.config are already installed.
XBuild Engine Version 14.0
Mono, Version 5.0.1.1
Copyright (C) 2005-2013 Various Mono authors
XBuild Engine Version 14.0
Mono, Version 5.0.1.1
Copyright (C) 2005-2013 Various Mono authors
Configuration: ReleaseMono Platform: x64
runtime.cs(284,17): warning CS0162: Unreachable code detected
Configuration: ReleaseMono Platform: x64
Configuration: ReleaseMono Platform: x64
dynamic.cs(121,28): warning CS0618: 'PythonEngine.RunString(string, IntPtr?, IntPtr?)' is obsolete: 'RunString is deprecated and will be removed. Use Exec/Eval/RunSimpleString instead.'
TestPythonEngineProperties.cs(171,17): warning CS0162: Unreachable code detected
Configuration: ReleaseMono Platform: x64
building 'clr' extension
creating build
creating build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/src
creating build/temp.linux-x86_64-2.7/src/monoclr
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c src/monoclr/pynetinit.c -o build/temp.linux-x86_64-2.7/src/monoclr/pynetinit.o -D_REENTRANT -I/usr/lib/pkgconfig/../../include/mono-2.0 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include
src/monoclr/pynetinit.c: In function ‘main_thread_handler’:
src/monoclr/pynetinit.c:101:17: warning: variable ‘init_result’ set but not used [-Wunused-but-set-variable]
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c src/monoclr/clrmod.c -o build/temp.linux-x86_64-2.7/src/monoclr/clrmod.o -D_REENTRANT -I/usr/lib/pkgconfig/../../include/mono-2.0 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include
src/monoclr/clrmod.c:31:18: warning: function declaration isn’t a prototype [-Wstrict-prototypes]
gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro build/temp.linux-x86_64-2.7/src/monoclr/pynetinit.o build/temp.linux-x86_64-2.7/src/monoclr/clrmod.o -o /home/dclark/python/pythonnet/pythonnet/clr.so -L/usr/lib/pkgconfig/../../lib -lmono-2.0 -lm -lrt -ldl -lpthread -lglib-2.0`
Not really sure what's going on except that there is 'unreachable code'.
den-run-ai commentedon Jul 5, 2017
@laskeym I don't see any errors, did the build fail? Also see this section in wiki:
https://github.com/pythonnet/pythonnet/wiki/Troubleshooting-on-Windows,-Linux,-and-OSX#2-build-and-install-from-command-line