Repository: pythonnet/pythonnet

Issue #392: Libraries missing after setup.py install on OSX
Created: 2017-02-18T15:42:45Z
Environment

Pythonnet version: v2.2.0-dev1-26-gb1cd3d1 (git describe --tags), branch mac-osx
Python version: Python 3.5.2 :: Anaconda 4.3.0 (x86_64)
Operating System: OSX El Capitan 10.11.6

Details


Checked out the branch, and run python setup.py install. This worked, after setting
'PKG_CONFIG_PATH=/Library/Frameworks/Mono.framework/Versions/4.6.2/lib/pkgconfig`
(see dump below)


Import fails


(py35) vasilios@exumas:~/Temp/pythonnet [mac-osx | ✚1 …2]
└─ $ python -c "import clr"
The assembly mscorlib.dll was not found or could not be loaded.
It should have been installed in the `/usr/local/anaconda/envs/py35/lib/mono/4.5/mscorlib.dll' directory.

Manually added a symbolic link to the respective mono folder, and trying import again

vasilios@exumas: /usr/local/anaconda/envs/py35/lib
└─ $ ln -s /Library/Frameworks/Mono.framework/Versions/Current/lib/mono
(py35) vasilios@exumas:~/Temp/pythonnet [mac-osx | ✚1 …2]
└─ $ python -c "import clr"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: System.TypeInitializationException: The type initializer for 'Mono.Unix.Native.Stdlib' threw an exception. ---> System.DllNotFoundException: MonoPosixHelper
  at (wrapper managed-to-native) Mono.Unix.Native.Stdlib:GetDefaultSignal ()
  at Mono.Unix.Native.Stdlib..cctor () [0x00006] in <ebe430c916fe49219627b20fd4c89313>:0 
   --- End of inner exception stack trace ---
  at Mono.Unix.UnixMarshal.AllocHeap (System.Int64 size) [0x00018] in <ebe430c916fe49219627b20fd4c89313>:0 
  at Mono.Unix.UnixMarshal.StringToHeap (System.String s, System.Int32 index, System.Int32 count, System.Text.Encoding encoding) [0x00061] in <ebe430c916fe49219627b20fd4c89313>:0 
  at Mono.Unix.UnixMarshal.StringToHeap (System.String s, System.Text.Encoding encoding) [0x00008] in <ebe430c916fe49219627b20fd4c89313>:0 
  at Python.Runtime.Utf32Marshaler.MarshalManagedToNative (System.Object obj) [0x00019] in <e8f6e1fa95374383b3f862986f3e768c>:0 
  at (wrapper managed-to-native) Python.Runtime.Runtime:PyUnicode_FromKindAndString (int,string,int)
  at Python.Runtime.Runtime.PyUnicode_FromUnicode (System.String s, System.Int32 size) [0x00000] in <e8f6e1fa95374383b3f862986f3e768c>:0 
  at Python.Runtime.Runtime.PyUnicode_FromString (System.String s) [0x00007] in <e8f6e1fa95374383b3f862986f3e768c>:0 
  at Python.Runtime.Runtime.Initialize () [0x0010f] in <e8f6e1fa95374383b3f862986f3e768c>:0 
  at Python.Runtime.PythonEngine.Initialize () [0x00014] in <e8f6e1fa95374383b3f862986f3e768c>:0 
  at Python.Runtime.PythonEngine.InitExt () [0x00000] in <e8f6e1fa95374383b3f862986f3e768c>:0 
Still looking at this issue, just though this may take you a step further. Any help would appreciated.
Output of Step 1
(py35) vasilios@exumas:~/Temp/pythonnet [mac-osx | ✔]
└─ $ set | grep PKG
PKG_CONFIG_PATH=/Library/Frameworks/Mono.framework/Versions/4.6.2/lib/pkgconfig

(py35) vasilios@exumas:~/Temp/pythonnet [mac-osx | ✔]
└─ $ python setup.py install
/usr/local/anaconda/envs/py35/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/setuptools/dist.py:331: UserWarning: Normalizing '2.2.0-dev1' to '2.2.0.dev1'
running install
running bdist_egg
running egg_info
writing pythonnet.egg-info/PKG-INFO
writing top-level names to pythonnet.egg-info/top_level.txt
writing dependency_links to pythonnet.egg-info/dependency_links.txt
reading manifest file 'pythonnet.egg-info/SOURCES.txt'
writing manifest file 'pythonnet.egg-info/SOURCES.txt'
installing library code to build/bdist.macosx-10.6-x86_64/egg
running install_lib
running build_ext
Checking for updates from https://www.nuget.org/api/v2/.
Currently running NuGet.exe 3.5.0.
NuGet.exe is up to date.
MSBuild auto-detection: using msbuild version '14.1' from '/Library/Frameworks/Mono.framework/Versions/Current/lib/mono/msbuild/14.1/bin/'.
All packages listed in packages.config are already installed.
XBuild Engine Version 14.0
Mono, Version 4.6.2.0
Copyright (C) 2005-2013 Various Mono authors
/Users/vasilios/Temp/pythonnet/pythonnet.sln:  warning : The project configuration for project 'clrmodule' corresponding to the solution configuration 'ReleaseMono|x64' was not found.
XBuild Engine Version 14.0
Mono, Version 4.6.2.0
Copyright (C) 2005-2013 Various Mono authors
		Configuration: ReleaseMono Platform: x64
assemblymanager.cs(206,37): warning CS0168: The variable `e' is declared but never used
classderived.cs(143,26): warning CS0219: The variable `fb' is assigned but its value is never used
classderived.cs(832,17): warning CS0219: The variable `t' is assigned but its value is never used
methodbinder.cs(145,36): warning CS0219: The variable `typeArgs' is assigned but its value is never used
methodbinding.cs(114,25): warning CS0219: The variable `len' is assigned but its value is never used
methodbinding.cs(153,24): warning CS0219: The variable `superType' is assigned but its value is never used
runtime.cs(2063,16): warning CS0472: The result of comparing value type `System.IntPtr' with null is always `true'
converter.cs(26,21): warning CS0414: The private field `Python.Runtime.Converter.decimalType' is assigned but its value is never used
/Users/vasilios/Temp/pythonnet/pythonnet.sln:  warning : The project configuration for project 'clrmodule' corresponding to the solution configuration 'ReleaseMono|x64' was not found.
Configuration: ReleaseMono Platform: x64
fieldtest.cs(21,17): warning CS0219: The variable `i' is assigned but its value is never used
fieldtest.cs(22,17): warning CS0219: The variable `j' is assigned but its value is never used
arraytest.cs(45,23): warning CS0414: The private field `Python.Test.PrivateArrayTest.items' is assigned but its value is never used
Configuration: ReleaseMono Platform: x64
pyimport.cs(47,17): warning CS0219: The variable `r' is assigned but its value is never used
Configuration: Release Platform: x64
assemblyinfo.cs(13,50): warning CS0618: `System.Security.Permissions.SecurityAction.RequestMinimum' is obsolete: `This requests should not be used'
pythonconsole.cs(18,28): warning CS0219: The variable `a' is assigned but its value is never used
creating build/bdist.macosx-10.6-x86_64
creating build/bdist.macosx-10.6-x86_64/egg
copying build/lib.macosx-10.6-x86_64-3.5/clr.cpython-35m-darwin.so -> build/bdist.macosx-10.6-x86_64/egg
creating stub loader for clr.cpython-35m-darwin.so
byte-compiling build/bdist.macosx-10.6-x86_64/egg/clr.py to clr.cpython-35.pyc
installing package data to build/bdist.macosx-10.6-x86_64/egg
running install_data
copying /Users/vasilios/Temp/pythonnet/build/lib.macosx-10.6-x86_64-3.5/Python.Runtime.dll -> build/bdist.macosx-10.6-x86_64/egg/../../../../../../../usr/local/anaconda/envs/py35/lib/python3.5/site-packages
creating build/bdist.macosx-10.6-x86_64/egg/EGG-INFO
copying pythonnet.egg-info/PKG-INFO -> build/bdist.macosx-10.6-x86_64/egg/EGG-INFO
copying pythonnet.egg-info/SOURCES.txt -> build/bdist.macosx-10.6-x86_64/egg/EGG-INFO
copying pythonnet.egg-info/dependency_links.txt -> build/bdist.macosx-10.6-x86_64/egg/EGG-INFO
copying pythonnet.egg-info/not-zip-safe -> build/bdist.macosx-10.6-x86_64/egg/EGG-INFO
copying pythonnet.egg-info/top_level.txt -> build/bdist.macosx-10.6-x86_64/egg/EGG-INFO
writing build/bdist.macosx-10.6-x86_64/egg/EGG-INFO/native_libs.txt
creating 'dist/pythonnet-2.2.0.dev1-py3.5-macosx-10.6-x86_64.egg' and adding 'build/bdist.macosx-10.6-x86_64/egg' to it
removing 'build/bdist.macosx-10.6-x86_64/egg' (and everything under it)
Processing pythonnet-2.2.0.dev1-py3.5-macosx-10.6-x86_64.egg
removing '/usr/local/anaconda/envs/py35/lib/python3.5/site-packages/pythonnet-2.2.0.dev1-py3.5-macosx-10.6-x86_64.egg' (and everything under it)
creating /usr/local/anaconda/envs/py35/lib/python3.5/site-packages/pythonnet-2.2.0.dev1-py3.5-macosx-10.6-x86_64.egg
Extracting pythonnet-2.2.0.dev1-py3.5-macosx-10.6-x86_64.egg to /usr/local/anaconda/envs/py35/lib/python3.5/site-packages
pythonnet 2.2.0.dev1 is already the active version in easy-install.pth

Installed /usr/local/anaconda/envs/py35/lib/python3.5/site-packages/pythonnet-2.2.0.dev1-py3.5-macosx-10.6-x86_64.egg
Processing dependencies for pythonnet==2.2.0.dev1
Finished processing dependencies for pythonnet==2.2.0.dev1

Duplicate issue #120: Python.Runtime.dll.config under Mac OSX, Anaconda and brew mono
Created: 2016-01-26T03:09:50Z
Hi,
First I installed mono with brew:
brew install mono
With anaconda under OSX El Capitan I managed to install pythonnet with no issues the development version with
pip install --pre pythonnet
Then, when trying to import clr in python I got the error
ImportError: System.DllNotFoundException: libpython2.7.so
I noticed the error was in Python.Runtime.dll.config since it assumes that any non-windows OS will have .so as extension for the libpython library; by example libpython2.7**.so** , but in anaconda and OSX, this should be libpython2.7.dylib.
This can be easily fixed by being more specific in Python.Runtime.dll.config about the os, such as:
<dllmap dll="python27.dll" target="libpython2.7.dylib" os="osx" />
<dllmap dll="python27" target="libpython2.7.so" os="linux" />
after modifying lib/python2.7/site-packages/Python.Runtime.dll.config using the previous convention then "import clr" works. All my code that uses pythonnet in Windows works with no issues in OSX. I'm attaching the modified Python.Runtime.dll.config. I do not know if other python installations in OSX have a different extension other than .dylib. AFAIR, Canopy uses also dylib, which is the standard for OSX dynamic libraries.
Regards
Sam
Python.Runtime.dll.config.zip

Closing comment (2017-02-24T22:33:38Z): @vmuriart -- No, just the changes reported in #392.