Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot import name '_core' #423

Open
1584319 opened this issue Oct 22, 2022 · 11 comments
Open

cannot import name '_core' #423

1584319 opened this issue Oct 22, 2022 · 11 comments

Comments

@1584319
Copy link

1584319 commented Oct 22, 2022

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)

@Kaiwen-Hong
Copy link

I also encounter this problem in my Ubuntu 18.04 system.

@CosteaPaul
Copy link

CosteaPaul commented Jan 3, 2023

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

@jeremybk21
Copy link

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

@stevewells20
Copy link

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.

@dariomangoni
Copy link
Member

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.

@RichiGit97
Copy link

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

@dariomangoni
Copy link
Member

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

@glennra
Copy link

glennra commented Jul 13, 2023

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)

@glennra
Copy link

glennra commented Jul 13, 2023

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

I installed it to $HOME/opt.

@TroyZhangFawang
Copy link

"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.

@TheCrazyT
Copy link

Talking about linux systems:
Problem source seems to be an old system with old glibc libraries. (atleast thats what the "ldd"-command on the "_core.so" tells me)
So you only have 2 solutions:

  • upgrade the system
  • downgrade the pychrono version (and code that uses it)

Not so shure about windows system.
Could be possible that another dependency is missing.
Maybe use tools like "dependency walker" to figure it out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants