1

I have written a small python package that I would like to install locally through pip. I used to do this by navigating to the package directory with the setup.py file, and then running pip install . after which the pip installer goes through the cycle and notifies me that it succesfully installed the package. When I check pip freeze, it is indeed listed there. However, when I then launch the Python interpreter and try to import my package, it throws a ModuleNotFoundError.

However, when I install through pip install -e ., this is not the case and it imports without problem.

I have used this approach already multiple times with other packages, but I can't seem to find why it keeps failing this particular time. I have already tried it with 2 different virtualenv's, verified I was using the right interpreter each time, but to no avail.

Thanks for the help!

lcdumort
  • 599
  • 3
  • 20

1 Answers1

1

I've been able to address the problem! It is based on this solution.

I wrote a setup.py file, but in the setup part I did not include packages=find_packages(). Therefore, it only installed some information about the package, but nothing of the package itself. That was the reason why it showed up in pip freeze, but failed to import.

my setup now looks like this

setup(
    name='package name',
    version=__version__,
    description='package description',
    long_description=readme,
    author='my name',
    author_email='my mail',
    url='https://link_to_github_site.com',
    packages=find_packages(),
    license=license
)
lcdumort
  • 599
  • 3
  • 20