How to install python local package package?

Question

I installed a local package called credentialsusing

pip install -e c:\users\worker\src\clockwork\lib\credentials

But when I try to import a package from the sibling directory, it fails with ImporError:

cd c:\users\worker\src\clockwork\bank
python -c "import credentials"
...
ImportError: No module named 'credentials'

Confusingly, the package credentialsis listed as successfully installed, as shown at startup pip list:

...
credentials (1.0.0, c:\users\worker\src\clockwork\lib\credentials)
...

How to install a local package so that it can be imported?

Background

I am using Python 3.4 (32-bit). The package contains two files:

credentials\__init__.py
credentials\setup.py

The file __init__.pydefines one function. The file is setup.pyshort:

from distutils.core import setup

setup(name='credentials', version='1.0.0')

Bypass

I am currently adding a directory containing package ( c:\users\worker\src\clockwork\lib) to my variable PATHas a workaround. But my question is how to install the package correctly, so I do not need to change PATH.

+4
2

setup.py. :

from distutils.core import setup

setup(name='credentials', version='1.0.0', packages=['credentials'])

setup.py credentials, :

...\credentials\setup.py
...\credentials\credentials\__init__.py

.

Python ( ), @Mr_and_Mrs_D .

+4

python, , :

python -m pip install -e c:\users\worker\src\clockwork\lib\credentials

, , , , python, pip , . . :

+5

Source: https://habr.com/ru/post/1670965/


All Articles