简体   繁体   中英

Copied a package to site-packages, but pip doesn't list it. How can I make pip aware of the installed package?

I had to manually build a package and copy it to the site-packages directory. When I type pip list into a console it isn't listed, though I can use it in python scripts. How can I make pip aware of the package?

Installing it via pip is not an option.

You say "Installing it via pip is not an option.", but I'm assuming installing it via pip using a local copy still is. If so, the way to do that is to clone your library into a directory (say /my/lib/dir ), where the root of the source for the root package appears below /my/lib/dir (ex: if the package you want to install is imported as import foo , then you should have /my/lib/dir/foo ). If there is no file named setup.py in your copy of the code, then you need to create a simple one. Something like

# in a file called setup.py above the `foo` directory
from distutils.core import setup

setup(name='foo',
      version='1.0',
      packages=['foo'],
 )

Finally, run pip install . from /my/lib/dir .

It's definitely a hack, but making pip aware of a package without installing it via pip is asking for a hack :-)

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