Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't import module installed with pip (anaconda python)

I'm trying to use the ReadIM package with an anaconda environment (anaconda 4.7.12, python 3.8, pip 19.3.1), thus requiring me to use pip install readIM which succeeds, with the package found in conda list and pip list.

I have read a lot of posts talking about using the correct python and pip paths, my python where shows only my anaconda path, where I ran conda install pip beforehand, and then pip -V shows my pip is in my conda path.

I have tried conda update --all and pip uninstall readIM. I also read that it could be an issue with Jupyter notebook, hence in the conda command prompt I tried python then import readIM, which still gave me the same import error.

As advised on the source page, I tried installing by running python setup.py build install/python setup.py install in the source directory, however this gave me an error

cygwin TypeError: '>=' not supported between instances of 'NoneType' and 'str'

I am at a loss, any ideas?

Thanks, Mustafa.

UPDATE:

Managed to compile it from source successfully, but still get the same error:

(base) C:>python -m pip install ReadIM-0.8.2.tar.gz Processing c:\readim-0.8.2.tar.gz Building wheels for collected packages: ReadIM Building wheel for ReadIM (setup.py) ... done Created wheel for ReadIM: filename=ReadIM-0.8.2-cp37-cp37m-win_amd64.whl size=219546 sha256=90f8960a6f1f80ae62dc18eab4bcd31fb2a6dfd7da364a5c15fc37e6e2ce0360 Stored in directory: C:\Users\mi4517\AppData\Local\pip\Cache\wheels\d6\a9\11\936e986255027bb654601b322a3431f9bcc3fde72ebb406835 Successfully built ReadIM Installing collected packages: ReadIM Successfully installed ReadIM-0.8.2

(base) C:>python Python 3.7.5 (default, Oct 31 2019, 15:18:51) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32 Type "help", "copyright", "credits" or "license" for more information.

import readIM Traceback (most recent call last): File "", line 1, in ModuleNotFoundError: No module named 'readIM'>

Following their instructions (python setup.py build install then python setup.py test) yields a successful build but a failed test:

C:\ReadIM-0.8.2>python setup.py test Traceback (most recent call last): File "setup.py", line 41, in assert os.path.isdir(testFileDir) AssertionError

SOLUTION

It was installing correctly, just that I was importing it incorrectly in Python. I was doing import readIM or import readim when it should be import ReadIM I did not know it was case sensitive!

Thank you for your help, apologies for the trivial mistake on my part.

like image 835
Mustafa Iqbal Avatar asked Nov 29 '19 16:11

Mustafa Iqbal


People also ask

Why is pip install not working?

This error usually means there's a problem with the Python installation or the system variable PATH is not set up correctly. Try reinstalling Python and all its components to fix the problem. The easiest way is via the Python executable installer.


3 Answers

I had faced a similar issue. With your conda environment activated, type

which pip

Check if it shows the path to pip in your environment. In my case, it was not. It was showing path to some other pip. So pip install was installing in that environment. To fix use the full path of pip, like below

~/anaconda3/envs/my_env/bin/pip install ... 
like image 106
Nagabhushan S N Avatar answered Oct 10 '22 01:10

Nagabhushan S N


To avoid this issue follow these steps

  1. open Anaconda prompt
  2. type this command conda install -c conda-forge imread
  3. after installation open jupiter notebook.
  4. type import imread then run.
like image 21
Kalana Avatar answered Oct 10 '22 00:10

Kalana


It was installing correctly, just that I was importing it incorrectly in Python. I was doing import readIM or import readim when it should be import ReadIM I did not know it was case sensitive!

Thank you for your help, apologies for the trivial mistake on my part.

like image 3
Mustafa Iqbal Avatar answered Oct 10 '22 01:10

Mustafa Iqbal