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

pyTME circular import error #13

Open
DcShepherd opened this issue Aug 13, 2024 · 4 comments
Open

pyTME circular import error #13

DcShepherd opened this issue Aug 13, 2024 · 4 comments

Comments

@DcShepherd
Copy link

Hello,

I have been following the tutorial for the installation of pyTME but I am running into this error when I run the pytest protocol.

============================================================================================= test session starts ==============================================================================================
platform linux -- Python 3.11.9, pytest-8.3.2, pluggy-1.5.0
rootdir: /home/doulin/clones/pyTME
configfile: pyproject.toml
plugins: napari-0.5.1, napari-plugin-engine-0.2.0, npe2-0.7.7
collected 0 items / 17 errors                                                                                                                                                                                  

==================================================================================================== ERRORS ====================================================================================================
___________________________________________________________________________ ERROR collecting tme/tests/preprocessing/test_compose.py ___________________________________________________________________________
ImportError while importing test module '/home/doulin/clones/pyTME/tme/tests/preprocessing/test_compose.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
tme/tests/preprocessing/test_compose.py:3: in <module>
    from tme.preprocessing import Compose
tme/__init__.py:1: in <module>
    from . import extensions
E   ImportError: cannot import name 'extensions' from partially initialized module 'tme' (most likely due to a circular import) (/home/doulin/clones/pyTME/tme/__init__.py)

Furthermore, check to see if the preprocess.py is working but then I get a similar error

preprocess.py --help
Traceback (most recent call last):
  File "/home/doulin/miniconda3/envs/pytme/bin/preprocess.py", line 12, in <module>
    from tme import Preprocessor, Density
  File "/home/doulin/clones/pyTME/tme/__init__.py", line 1, in <module>
    from . import extensions
ImportError: cannot import name 'extensions' from partially initialized module 'tme' (most likely due to a circular import) (/home/doulin/clones/pyTME/tme/__init__.py)

I tried deleting and reinstalling multiple times but I get the same error. Would you be able to point out where I might have made of a mistake during the installation.

@maurerv
Copy link
Collaborator

maurerv commented Aug 13, 2024

Hi @DcShepherd,

Thank you for reaching out. pytme comes with a set of c extensions that help performance but can be a bit tricky to build. I reproduce your error when installing like this

git clone https://github.com/KosinskiLab/pyTME.git
cd pyTME
python3 -mpip install .

Installing the library in editable mode fixed the issue for me python3 -mpip install -e .. The other installation methods should also yield a working installation though (https://kosinskilab.github.io/pyTME/quickstart/installation.html).

Which installation method did you use? :)

@DcShepherd
Copy link
Author

Hi, Thanks for the quick reply, my installation process is shown below from this page: https://kosinskilab.github.io/pyTME/quickstart/installation.html

  1. Conda environment set up
conda create \
   --name pytme \
   -c conda-forge \
   python=3.11 \
   pyfftw \
   napari \
   magicgui \
   pyqt
  1. Then activate the environment and run the following.
conda activate pytme
pip install git+https://github.com/KosinskiLab/pyTME.git
  1. Install Cupy
pip install "pytme[cupy]"
  1. Install the GUI
pip install git+https://github.com/maurerv/napari-density-io.git

The good new is that the python3 -mpip install -e command seems to have fixed the issue

@maurerv
Copy link
Collaborator

maurerv commented Aug 14, 2024

Hi,

Thank you for sharing the installation process. I am glad to hear pytme is working now.

I was able to reproduce your error and have updated the installation instructions accordingly. Re-installing in editable mode did solve the issue, but it is a temporary solution at best. The editable mode can be avoided by modifying the file structure of the package. I plan to integrate this in the next 0.2.4 release.

Thanks again for reporting :)

@DcShepherd
Copy link
Author

Hello,

Thanks for the info! I also had to install Pytorch rather than CuPy to get all the test to pass. I'll have to check if it is a config problem with this machine.

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

2 participants