projectchrono/chrono

cannot import name '_core'

1584319 opened this issue · 10 comments

Hello, I did fresh installation on my Windows and I've encountered with the running issue.
My script failed on the line import pychrono as chrono where after run under the spyder I've got this error message

runfile('C:/Users/.spyder-py3/temp.py', wdir='C:/Users/LEGION/.spyder-py3')
Traceback (most recent call last):

  File "D:\Anaconda3\envs\chrono\lib\site-packages\spyder_kernels\py3compat.py", line 356, in compat_exec
    exec(code, globals, locals)

  File "c:\users\legion\.spyder-py3\temp.py", line 4, in <module>
    import pychrono as chrono

  File "D:\Anaconda3\envs\chrono\lib\site-packages\pychrono\__init__.py", line 48, in <module>
    from .core import *

  File "D:\Anaconda3\envs\chrono\lib\site-packages\pychrono\core.py", line 13, in <module>
    from . import _core

ImportError: cannot import name '_core' from partially initialized module 'pychrono' (most likely due to a circular import) (D:\Anaconda3\envs\chrono\lib\site-packages\pychrono\__init__.py)

I also encounter this problem in my Ubuntu 18.04 system.

Same:

File "/root/miniconda3/envs/chrono/lib/python3.10/site-packages/pychrono/init.py", line 54, in
from .core import *
File "/root/miniconda3/envs/chrono/lib/python3.10/site-packages/pychrono/core.py", line 13, in
from . import _core
ImportError: cannot import name '_core' from partially initialized module 'pychrono' (most likely due to a circular import) (/root/miniconda3/envs/chrono/lib/python3.10/site-packages/pychrono/init.py)

Did the conda install with the latest release here:
https://anaconda.org/projectchrono/pychrono/7.0.0/download/linux-64/pychrono-7.0.0-py310_2455.tar.bz2

Btw, this is on python 3.10

I also encounter this issue on windows with python 3.9 & both pychrono v7 and 8. Any solution would be greatly appreciated!

Same here, Ubuntu 20.04, building from source. I've tried on a venv of 3.10 and 3.11, on the OS installation of 3.8. All receive the same error as CosteaPaul.

Unfortunately we have seen many users affected by this issue (during hands-on sessions it was really a nightmare!) but so far we failed in spotting the cause: apparently some users were affected while others did not. And this was independent from the OS, the Python or the PyChrono version.

While we investigate the issue we suggest those keenest users to build PyChrono by their own from C++ source (section B here).
The issue does not show up in this case.

I had the same problem with the pychrono module on Windows 11, using Python 3.9 and the latest version of anaconda. It seems that the problem has now been resolved by changing the environment variables and adding the anaconda path.
Afterward, open "Anaconda Powershell Prompt" and run conda init powershell. Then close anaconda powershell and reopen it.
By doing this, the problem seems to be solved.
I tried running a few demos and they all worked.
9

Thanks Riccardo, it would be great if also other users can confirm that the fix applies also to them!

I have a similar issue. This is on Fedora37 using chrono I've built from source.

(venv) glenn@fedora:~/devel/chrono/build$ env | grep PYTHONPATH
PYTHONPATH=/home/glenn/opt/share/chrono/python
(venv) glenn@fedora:~/devel/chrono/build$ python
Python 3.11.4 (main, Jun  7 2023, 00:00:00) [GCC 12.3.1 20230508 (Red Hat 12.3.1-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pychrono
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/glenn/opt/share/chrono/python/pychrono/__init__.py", line 63, in <module>
    from .core import *
  File "/home/glenn/opt/share/chrono/python/pychrono/core.py", line 13, in <module>
    from . import _core
ImportError: cannot import name '_core' from partially initialized module 'pychrono' (most likely due to a circular import) (/home/glenn/opt/share/chrono/python/pychrono/__init__.py)

I've got it working by setting:
export LD_LIBRARY_PATH=~/opt/lib

I installed it to $HOME/opt.

"ImportError: cannot import name '_core' from partially initialized module 'pychrono' (most likely due to a circular import)"
Has anyone solved this error? I tried different python version on ubuntu 18.04, but it all failed.