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

ImportError: cannot import name 'path' from 'path' #117

Closed
hungyiwu opened this issue Nov 12, 2019 · 6 comments · Fixed by #123
Closed

ImportError: cannot import name 'path' from 'path' #117

hungyiwu opened this issue Nov 12, 2019 · 6 comments · Fixed by #123

Comments

@hungyiwu
Copy link

I cloned this repo and ran pytest on the test folder. I got 33 errors, 32 of which were the same:

ImportError: cannot import name 'path' from 'path'

I went to these import code and felt they are probably calling the path.py library (link). Does the code meant to be this?

from path import Path

Pytest result is attached here:
pytest_stdout.txt

@joshmoore
Copy link
Member

Good morning, @hywu0110 . Thanks for helping to test. Can you paste exactly the steps you took and tell us which platform you're using? e.g. I'm on OSX using conda:

conda create -n py37 python=3.7
source activate py37
cd /tmp
git clone git://github.com/ome/omero-py
cd omero-py
pip install zeroc-ice
pip install mox3 tables numpy pillow
pip install -e .
pytest -m "not broken" -svx test

shows me one error that I'll look into, but nothing about path.

@hungyiwu
Copy link
Author

I'm using a Linux container on top of a Chrome OS. The Linux distro is Debian 9 (stretch) and I used Anaconda (python 3). Here's what I did:

git clone https://github.com/ome/omero-py.git
cd omero-py
python setup.py devtarget
pip install -e .
pytest test

The python setup.py devtarget was found in the README page of this repo. I first tried python setup.py but it failed, so I followed the README, knowing that this is probably for developers but I'm not trying to develop more code.

I noticed that you used pytest -m "not broken" -svx test. I'm not very familiar with pytest, but after a quick glance of articles online I just tried pytest test at that time.

Let me know if you need more information.

@joshmoore
Copy link
Member

Hi @hywu0110. Sorry for the slow response. It took a bit to get https://github.com/ome/conda-zeroc-ice36-python working (see: https://anaconda.org/ome/zeroc-ice36-python) so that I could reproduce your setup:

FROM debian:stretch
RUN apt-get update -y
RUN apt-get install -y curl bzip2
RUN curl -O https://repo.anaconda.com/archive/Anaconda3-5.2.0-Linux-x86_64.sh \
 && bash Anaconda3-5.2.0-Linux-x86_64.sh -b && rm Anaconda3-5.2.0-Linux-x86_64.sh
ENV PATH /root/anaconda3/bin/:$PATH
RUN echo 'python 3.6.*' >> /root/anaconda3/conda-meta/pinned
RUN conda install -c ome zeroc-ice36-python
RUN apt-get install -y git
RUN git clone git://github.com/ome/omero-py /tmp/py
WORKDIR /tmp/py
RUN python setup.py devtarget
RUN pip install -e .
RUN pip install mox3
ENTRYPOINT ["pytest", "test"]

Turns out, though, that the answer was fairly straight-forward: anaconda ships with its own version of path.py and

diff /root/anaconda3/lib/python3.6/site-packages/path.py src/path.py

shows a number of differences.

#123 will hopefully fix the issue.

@hungyiwu
Copy link
Author

@joshmoore Ah I didn't realize docker is great for reproducing issues (this is docker script, right?). Thank you for the effort! I'll learn to provide docker scripts next time when reporting issues to projects on Github. Please feel free to close this issue when you see fit.

@joshmoore
Copy link
Member

And thank you for finding the problem! Docker scripts are definitely welcome on any issue you open, but we have lots of examples, so not a necessity. (Every little bit helps.)

@SystemDZ
Copy link

It's just a typo in the code, you definitely forget some words in the code
make sure
for example
from django.urls import path, include

instead of
from django import path, include

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

Successfully merging a pull request may close this issue.

3 participants