Python 3 fails to install pip and initialize

Hello,
We’re currently having some issues when users attempt to run Script Editor in Rhino8.

Each time it fails to launch with an error of “Error Occurred During Language Initialization”:

Has anyone encountered this before? If so how can I remedy this.

Thanks!

1 Like

Hi Licencing -

The current version of Rhino 8 is 8.5. Please update your installation.
-wim

Hi Wim,

Thanks for that, unfortunately I’ve updated to Rhino 8.5 and still encounter the same error when attempting to launch ScriptEditor

Thanks,
Brett

Here is the log if this helps

error dump from get_pip.py run with wheel packages:

stderr: Traceback (most recent call last):  File "C:\Users\patbj\.rhinocode\py39-rh8\get_pip.py", line 24274,
 in <module> main()  File "C:\Users\patbj\.rhinocode\py39-rh8\get_pip.py", line 101,
 in main    bootstrap(tmpdir=tmpdir)  File "C:\Users\patbj\.rhinocode\py39-rh8\get_pip.py", line 76,
 in bootstrap    monkeypatch_for_cert(tmpdir)  File "C:\Users\patbj\.rhinocode\py39-rh8\get_pip.py", line 57,
 in monkeypatch_for_cert    from pip._internal.commands.install import InstallCommand  File "<frozen zipimport>", line 259,
 in load_module  File "C:\Users\patbj\AppData\Local\Temp\tmp8jqh2kqi\pip.zip\pip\_internal\commands\__init__.py", line 9,
 in <module>  File "<frozen zipimport>", line 259,
 in load_module  File "C:\Users\patbj\AppData\Local\Temp\tmp8jqh2kqi\pip.zip\pip\_internal\cli\base_command.py", line 4,
 in <module>  File "<frozen zipimport>", line 259,
 in load_module  File "logging\config.py", line 30,
 in <module>  File "<frozen zipimport>", line 259,
 in load_module  File "logging\handlers.py", line 26,
 in <module>  File "<frozen zipimport>", line 259,
 in load_module  File "socket.py", line 51,
 in <module>ImportError: dynamic module does not define module export function (PyInit__socket) 
   at Rhino.Runtime.Code.Languages.PythonNet.CPythonRuntime.DeployCPythonRuntime(CPythonStartupSteps startup)
   at Rhino.Runtime.Code.Languages.PythonNet.CPythonRuntime.<>c__DisplayClass98_0.<InitRuntime>b__0(Access access)
   at Rhino.Runtime.Code.Languages.Runtime.Access.Run(String id, Action`1 task)
   at Rhino.Runtime.Code.Languages.PythonNet.CPythonRuntime.InitRuntime(CPythonStartupSteps startup)
   at Rhino.Runtime.Code.Languages.PythonNet.CPython`1.Start()

@licencing

See this thread please (Rhino 8 - Importing Python 3 Libraries - #18 by Thomas_Dowse)

Python is failing to import the _socket module and it is throwing this error:

in <module>ImportError: dynamic module does not define module export function (PyInit__socket) 

It is identical to the error message in the post that I shared above. This ususally happens when security policies on windows prevent Rhino from loading external libraries. Would you mind checking with your IT department on this?

On a related note, Python 3 tries to install pip from internet if it has access and if not it falls back on its own embedded pip. I will improve the install process

RH-80990 Try to install pip from embedded if get_pip fails

1 Like

Thanks Ehsan, appreciate it!

1 Like

I have the same problem, may I ask how you ultimately resolved it

Hallo, I have the same problem that the Python Editor does not start.


It worked before und suddenly, I did not make any change in Rhino, I got this problem.
Changing the system language to English-US as workaround does not work.
Now I have to use an old version of Rhino, that has serveral other problems in the script-editor (the windows disapears often). I would be very happy for any hint or if needed I can’t try to help to reproduce to fix the problem.

@Konrad_Wöllhaf Would you mind running RhinoCodeLogs after script editor is opened and shows Python failure and DM me the log contents. There should be more information there about the error.

Also try resetting the runtime and start clean:

Hallo Ehsan Iran-Nejad,
thank you very much for your help. The log is in the text-file attached.
As you can see above cause of the error most of the menu-commands are disabled.
RhinoCodeLogs.txt (7.6 KB)

Thanks for the error report. I can see this error:

Error 29.10.2024 09:08:04 [RhinoCode] Error Initializing Python | Error loading CPython engine | System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
 ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at Python.Runtime.Runtime.get_InteropModule()
   at Python.Runtime.PythonException.TryDecodePyErr(BorrowedReference typeRef, BorrowedReference valRef, BorrowedReference tbRef)
   at Python.Runtime.PythonException.FetchCurrentOrNull(ExceptionDispatchInfo& dispatchInfo)
   at Python.Runtime.PythonException.ThrowLastAsClrException()
   at Python.Runtime.Runtime.SetPyMember(PyObject& obj, StolenReference value)
   at Python.Runtime.Runtime.InitPyMembers()
   at Python.Runtime.Runtime.Initialize(Boolean initSigs)
   at Python.Runtime.PythonEngine.Initialize(IEnumerable`1 args, Boolean setSysArgv, Boolean initSigs)
   at Python.Runtime.PythonEngine.Initialize(Boolean setSysArgv, Boolean initSigs)
   at Python.Runtime.PythonEngine.Initialize()

Here is the problem I think:

Info 29.10.2024 09:08:03 [RhinoCode] PYTHONPATH: C:\winpro\WinPython-64bit-3.6.3.0Qt5\python-3.6.3.amd64\DLLs;C:\winpro\WinPython-64bit-3.6.3.0Qt5\python-3.6.3.amd64\Lib;C:\winpro\WinPython-64bit-3.6.3.0Qt5\python-3.6.3.amd64\Lib\site-packages

Seems like there is a PYTHONPATH environment variable set on your machine that points to python 3.6 folders. It would be great if you can clean up this PYTHONPATH

Also please test Rhino 8.13 SRC as well to make sure this loads normally.

I changed the pythonpath in my Powershell-Script setPathPython2 to:
“C:\Program Files\Rhino 8\Plug-ins\IronPython”
where Rhino 8 is installed.
Now if I start the Script-Editor it tries to load Python and than Rhino crashes.
Which path I had to set for Python? I have different versions of python installed on my computer.
.\setPathPython2 “C:\Program Files\Rhino 8\Plug-ins\IronPython”
.\setPathPython2 “C:\Program Files (x86)\Cura_15.04.6\python”
.\setPathPython2 C:\Py\Python312
.\setPathPython2 C:\winpro\WinPython-64bit-3.6.3.0Qt5\python-3.6.3.amd64
Do I need another python-version than IronPython?

  • Remove PYTHONPATH from your environment variables or set it to empty
  • Test in Rhino 8.13 SRC

Thank you very much, after removing PYTHONPATH in the system-variables it works!
But I think it would be a good idea to remove this dependency from pythonpath. I also would like to use python the normal way.

1 Like

@Konrad_Wöllhaf did you test this in latest 8.13 SRC?

Thank you for your hint! Rhino tells me, that 8 12 SRC is the latest version, if I ask in the program, if there is an update. So I don’t know how to access 8.13.

Rhino 8 SR13 2024-10-29 (Rhino 8, 8.13.24303.13001 also crashes if the PYTHONPATH is set.

1 Like

Okay sweet. Thanks for testing

rhino code logs.txt (4.5 KB)
Hellow,
I have the same problem.