ome / omero-py

Python project containing Ice remoting code for OMERO
https://www.openmicroscopy.org/omero
GNU General Public License v2.0
22 stars 32 forks source link

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

Closed hungyiwu closed 5 years ago

hungyiwu commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

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.

https://github.com/ome/omero-py/pull/123 will hopefully fix the issue.

hungyiwu commented 5 years ago

@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 commented 5 years ago

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 commented 4 years ago

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