ImportError: cannot import name '_core' from partially initialized module 'pychrono' (most likely due to a circular import)
Issue
I recently installed Pychrono on Windows, following the instructions for option A) here. I was able to install everything as directed, but when I try to run the demo file demo_CH_coords.py from spyder and vscode I get the following error:
PS C:\Users\USERNAME\anaconda3\envs\chrono\Lib\site-packages\pychrono\demos> conda activate chrono
conda : The term 'conda' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if
a path was included, verify that the path is correct and try again.
At line:1 char:1
+ conda activate chrono
+
+ CategoryInfo : ObjectNotFound: (conda:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
PS C:\Users\USERNAME\anaconda3\envs\chrono\Lib\site-packages\pychrono\demos> & C:/Users/USERNAME/anaconda3/envs/chrono/python.exe c:/Users/TLab_PC_00/anaconda3/envs/chrono/Lib/site-packages/pychrono/demos/core/demo_CH_coords.py
First tutorial for PyChrono: vectors, matrices etc.
Traceback (most recent call last):
File "c:\Users\USERNAME\anaconda3\envs\chrono\Lib\site-packages\pychrono\demos\core\demo_CH_coords.py", line 17, in <module>
import pychrono as chrono
File "C:\Users\USERNAME\anaconda3\envs\chrono\lib\site-packages\pychrono\__init__.py", line 54, in <module>
from .core import *
File "C:\Users\USERNAME\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) (C:\Users\USERNAME\anaconda3\envs\chrono\lib\site-packages\pychrono\__init__.py)
I have read that this is a circular import issue online (and in the error obviously) but I have no idea where it is coming from, or how to fix it, seeing as this is all part of the installation process and I have not written any code yet myself.
What I've Tried
I did try creating a simple test file called test.py with only the import statement in it:
import pychrono as chrono
I get the same error when trying to run this file from the chrono venv in vscode.
Following the debug process in post #140 I tried installing Spyder in the chrono venv
conda install spyder
Opening it via the anaconda navigation terminal, and running demo_CH_coords.py. I get the same error
...
ImportError: cannot import name '_core' from partially initialized module 'pychrono' (most likely due to a circular import) (C:\Users\USERNAME\anaconda3\envs\chrono\lib\site-packages\pychrono\__init__.py)
I have also tried adding ...\anaconda3 and ...\anaconda3\Scripts paths to environment variables as suggested by RichiGit97 on post #423:
I get the same result running from spyder:
...
ImportError: cannot import name '_core' from partially initialized module 'pychrono' (most likely due to a circular import) (C:\Users\USERNAME\anaconda3\envs\chrono\lib\site-packages\pychrono\__init__.py)
Additional Information
For reference, I installed this version of pychrono: win-64_pychrono-8.0.0-py310_3631.tar.bz2 using this line from the instructions:
conda install win-64_pychrono-8.0.0-py310_3631.tar.bz2
And I have the following packages installed in the virtual environment chrono: (all installed during the installation process referenced above)
Name Version Build Channel
bzip2 1.0.8 vc14h5832a3a_5 [vc14] intel
ca-certificates 2023.7.22 h56e8100_0 conda-forge
cuda-cccl 11.7.58 0 nvidia/label/cuda-11.7.0
cuda-command-line-tools 11.7.0 0 nvidia/label/cuda-11.7.0
cuda-compiler 11.7.0 0 nvidia/label/cuda-11.7.0
cuda-cudart 11.7.60 0 nvidia/label/cuda-11.7.0
cuda-cudart-dev 11.7.60 0 nvidia/label/cuda-11.7.0
cuda-cuobjdump 11.7.50 0 nvidia/label/cuda-11.7.0
cuda-cupti 11.7.50 0 nvidia/label/cuda-11.7.0
cuda-cuxxfilt 11.7.50 0 nvidia/label/cuda-11.7.0
cuda-documentation 11.7.50 0 nvidia/label/cuda-11.7.0
cuda-libraries 11.7.0 0 nvidia/label/cuda-11.7.0
cuda-libraries-dev 11.7.0 0 nvidia/label/cuda-11.7.0
cuda-memcheck 11.7.50 0 nvidia/label/cuda-11.7.0
cuda-nsight-compute 11.7.0 0 nvidia/label/cuda-11.7.0
cuda-nvcc 11.7.64 0 nvidia/label/cuda-11.7.0
cuda-nvdisasm 11.7.50 0 nvidia/label/cuda-11.7.0
cuda-nvml-dev 11.7.50 0 nvidia/label/cuda-11.7.0
cuda-nvprof 11.7.50 0 nvidia/label/cuda-11.7.0
cuda-nvprune 11.7.50 0 nvidia/label/cuda-11.7.0
cuda-nvrtc 11.7.50 0 nvidia/label/cuda-11.7.0
cuda-nvrtc-dev 11.7.50 0 nvidia/label/cuda-11.7.0
cuda-nvtx 11.7.50 0 nvidia/label/cuda-11.7.0
cuda-nvvp 11.7.50 0 nvidia/label/cuda-11.7.0
cuda-sanitizer-api 11.7.50 0 nvidia/label/cuda-11.7.0
cuda-toolkit 11.7.0 0 nvidia/label/cuda-11.7.0
cuda-tools 11.7.0 0 nvidia/label/cuda-11.7.0
cuda-visual-tools 11.7.0 0 nvidia/label/cuda-11.7.0
expat 2.5.0 h63175ca_1 conda-forge
fontconfig 2.14.2 hbde0cde_0 conda-forge
freetype 2.12.1 hdaf720e_2 conda-forge
glfw 3.3.8 hcfcfb64_2 conda-forge
intel-openmp 2023.2.0 h57928b3_50497 conda-forge
intelpython 2023.2.0 0 intel
irrlicht 1.8.5 h65f4d7e_4 conda-forge
libblas 3.9.0 8_mkl conda-forge
libcblas 3.9.0 8_mkl conda-forge
libcublas 11.10.1.25 0 nvidia/label/cuda-11.7.0
libcublas-dev 11.10.1.25 0 nvidia/label/cuda-11.7.0
libcufft 10.7.2.50 0 nvidia/label/cuda-11.7.0
libcufft-dev 10.7.2.50 0 nvidia/label/cuda-11.7.0
libcurand 10.2.10.50 0 nvidia/label/cuda-11.7.0
libcurand-dev 10.2.10.50 0 nvidia/label/cuda-11.7.0
libcusolver 11.3.5.50 0 nvidia/label/cuda-11.7.0
libcusolver-dev 11.3.5.50 0 nvidia/label/cuda-11.7.0
libcusparse 11.7.3.50 0 nvidia/label/cuda-11.7.0
libcusparse-dev 11.7.3.50 0 nvidia/label/cuda-11.7.0
libexpat 2.5.0 h63175ca_1 conda-forge
libffi 3.4.2 h8ffe710_5 intel
libiconv 1.17 h8ffe710_0 conda-forge
libjpeg-turbo 3.0.0 hcfcfb64_1 conda-forge
liblapack 3.9.0 8_mkl conda-forge
libnpp 11.7.3.21 0 nvidia/label/cuda-11.7.0
libnpp-dev 11.7.3.21 0 nvidia/label/cuda-11.7.0
libnvjpeg 11.7.2.34 0 nvidia/label/cuda-11.7.0
libnvjpeg-dev 11.7.2.34 0 nvidia/label/cuda-11.7.0
libpng 1.6.39 h19919ed_0 conda-forge
libsqlite 3.42.0 hcfcfb64_0 intel
libzlib 1.2.13 hcfcfb64_5 intel
mkl 2020.4 hb70f87d_311 conda-forge
nsight-compute 2022.2.0.13 0 nvidia/label/cuda-11.7.0
numpy 1.24.0 py39hbccbffa_0 conda-forge
occt 7.4.0 h823b557_3 conda-forge
openssl 3.1.4 hcfcfb64_0 conda-forge
pip 23.1.2 pyhd8ed1ab_0 intel
python 3.9.16 h11da44f_23 intel
python_abi 3.9 2_cp39 conda-forge
pythonocc-core 7.4.1 py39h3d1c7c5_0 conda-forge
sdl 1.2.68 h21dd15a_0 conda-forge
sdl2 2.28.4 h63175ca_0 conda-forge
setuptools 67.7.2 pyhd8ed1ab_0 intel
six 1.16.0 pyh6c4a22f_0 conda-forge
tbb 2020.3 vc14_intel_311 [vc14] intel
tk 8.6.12 h2bbff1b_0 intel
tzdata 2023c h71feb2d_0 intel
ucrt 10.0.22621.0 h57928b3_0 intel
vc 14.3 hb25d44b_16 intel
vc14_runtime 14.34.31931 h5081d32_16 intel
vs2015_runtime 14.34.31931 hed1258a_16 intel
wheel 0.40.0 pyhd8ed1ab_0 intel
xz 5.2.8 h8cc25b3_0 intel`
Plea
Please let me know if I can offer any more information to help get this issue resolved. Would really love to get Pychrono working :)
Well, one possible issue (might be the solution tho) is that you can see your Python version from "conda list" is 3.9 while your PyChrono installation package is a "py310" version. So the issue might due to interpreter version mismatch. You can try to make them the same. (I solved mine on Ubuntu 20.04 by degrading PyChrono version to 7.0_py39)
Thank you for raising the issue. Our conda package building pipeline has recently changed and we haven't updated the document. We have simplified the installation process so you won't need to manually download and install packages as before. Could you please try using the following two command in the NEW environment to install PyChrono through conda? Thank you very much!
conda create -n chrono_test python=3.12 -c conda-forge
conda install pychrono -c projectchrono -c dlr-sc -c conda-forge