Search code examples
pythonanacondacondapython-packaging

Python does not find installed module


EDIT: Thanks to michcio1234, the problem is solved in the answer below.

ORIGINAL QUESTION: I created a python package (called precom), installed via pip install . into a defined conda environment (also called precom) and tried to load the package.

When loading the installed package in ipython, it is not found. However, when I do conda list, the package is listed (see output below).

This is really strange!

I googled, checked stack overflow, re-coded, re-installed but it never worked. Does anyone have an idea what I am missing?

(precom) C:\WINDOWS\system32>conda list
# packages in environment at C:\ProgramData\Anaconda3\envs\precom:
#
# Name                    Version                   Build  Channel
ca-certificates           2019.5.15                     0
certifi                   2019.6.16                py37_0
git                       2.20.1               h6bb4b03_0
openssl                   1.1.1c               he774522_1
pip                       19.1.1                   py37_0
precom                    0.1                      pypi_0    pypi
python                    3.7.3                h8c8aaf0_1
setuptools                41.0.1                   py37_0
sqlite                    3.28.0               he774522_0
vc                        14.1                 h0510ff6_4
vs2015_runtime            14.15.26706          h3a45250_4
wheel                     0.33.4                   py37_0
wincertstore              0.2                      py37_0

(precom) C:\WINDOWS\system32>ipython
Python 3.6.5 |Anaconda, Inc.| (default, Mar 29 2018, 13:32:41) [MSC v.1900 64 bit (AMD64)]
Type 'copyright', 'credits' or 'license' for more information
IPython 6.4.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import precom
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-1-e3942b1e7f0a> in <module>()
----> 1 import precom

ModuleNotFoundError: No module named 'precom'


Solution

  • You don't have ipython installed in your environment, so what you are running is not actually in your precom venv.

    Try pip install ipython or conda install ipython, or just run python and then try to import your package.