8000 macOS: AddReference find the reference, but the module is not found · Issue #643 · pythonnet/pythonnet · GitHub
[go: up one dir, main page]

Skip to content
macOS: AddReference find the reference, but the module is not found #643
Closed
@AlexCatarino

Description

@AlexCatarino

Environment

  • Pythonnet version: Latest
  • Python version: 3.6
  • Operating System: macOS

Details

We have compiled Python.Runtime.dll for python 3.6 in Windows for each OS: Windows, macOS and Linux. Then we create a nuget package to distribute the library (along with nPython.exe) to be used with Lean. The following commands were used:

msbuild pythonnet.sln /nologo /v:quiet /t:Clean;Rebuild /p:Platform=x64 /p:PythonInteropFile="interop36.cs" /p:Configuration=ReleaseWin /p:DefineConstants="PYTHON36,PYTHON3,UCS2"
msbuild pythonnet.sln /nologo /v:quiet /t:Clean;Rebuild /p:Platform=x64 /p:PythonInteropFile="interop36.cs" /p:Configuration=ReleaseMono /p:DefineConstants="PYTHON36,PYTHON3,UCS2,MONO_OSX"
msbuild pythonnet.sln /nologo /v:quiet /t:Clean;Rebuild /p:Platform=x64 /p:PythonInteropFile="interop36.cs" /p:Configuration=ReleaseMono /p:DefineConstants="PYTHON36,PYTHON3,UCS4,MONO_LIN
6206
UX"

When execute nPython.exe in Windows and try to import System, I can do it successfully:

C:\Users\Alex\Lean\Launcher\bin\Debug>nPython.exe
Python 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:54:40) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from clr import AddReference
>>> ref = AddReference("System")
>>> ref.FullName
'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
>>> import System
>>>

In Linux:

root@52578947ccd3:~/Lean/Launcher/bin/Debug# mono nPython.exe
Python 3.6.4 |Anaconda, Inc.| (default, Jan 16 2018, 18:12:19)
[GCC 7.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from clr import AddReference
>>> ref = AddReference("System")
>>> ref.FullName
'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
>>> import System
>>>

However, in macOS High Sierra:

Alexandres-Mac:Debug alex$ mono nPython.exe 
Python 3.6.4 |Anaconda, Inc.| (default, Jan 16 2018, 12:06:34) 
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from clr import AddReference
>>> ref = AddReference("System")
>>> ref.FullName
'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
>>> import System
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'System'

We added the symbolic link to the mono in python lib:

Alexandres-Mac:lib alex$ pwd
/Users/alex/anaconda3/lib
Alexandres-Mac:lib alex$ ls -lrt mono*
lrwxr-xr-x  1 alex  staff  60 Mar  9 04:07 mono -> /Library/Frameworks/Mono.framework/Versions/Current/lib/mono

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0