简体   繁体   中英

pip local package installed but not available - anaconda

I have created a package that I'd like to use locally, and have "successfully" installed it, according to pip.

Here is an excerpt from my terminal:

me@mycomp ~/Projects/donkey $ pip install -e .

Obtaining file:///home/daniel/Projects/donkey
Installing collected packages: donkey
Running setup.py develop for donkey
Successfully installed donkey

Here is my setup.py file, which is in the same directory (/Projects/donkey/)

from distutils.core import setup

setup(name="donkey",
    version="0.1",
    description="A package",
    url="nope",
    author="Me",
    author_email="my email",
    license="None",
    packages=[],
    zip_safe=False)

However, when I open an iPython session and run the following, I get an error.

[1] import donkey

ModuleNotFoundError: No module named 'donkey'

After uninstalling, it showed that the package which was uninstalled was at: /home/daniel/anaconda3/lib/python3.6/site-packages/donkey.egg-link

Upon re-installing, that file contained the following.

/home/daniel/Projects/donkey
.

Is there something missing in my setup.py file? Is there something odd about installing locally with anaconda? For completeness, I'm on Linux Mint 17.1

I'd like to use this package in various places, and appending to sys.path all the time seems like a bit of a cop-out.

Any help would be much appreciated.

You import a python code package or module, not a python distribution package. In order for your python donkey package to be available, you need to follow two steps:

  1. Make sure that donkey is indeed a package (includes a __init__.py file) and is importable.
  2. Include the donkey package inside the distribution by adding it to the packages list argument in setup() . This can be done automatically by using find_packages , as explained here: http://setuptools.readthedocs.io/en/latest/setuptools.html#using-find-packages

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM