Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

372
Visualizações
How to pip install a local python package?

Question

I installed a local package called credentials using

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

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

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

Confusingly, the package credentials is listed as successfully installed as shown when I run pip list:

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

How can I install my 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 __init__.py file defines a single function. The setup.py file is short:

from distutils.core import setup

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

Workaround

I currently add the directory containing the package (c:\users\worker\src\clockwork\lib) to my PATH variable as a workaround. But my question is how to install the package properly so that I do not need to modify the PATH.

over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

Uninstall the python package then install it using:

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

What is probably happening is that you have multiple python installs and pip is run from one install while you are trying to use the package from another. See also:

  • What's the difference between pip install and python -m pip install?
  • https://docs.python.org/3/installing/#basic-usage
over 4 years ago · Santiago Trujillo Relatório

0

The problem centers on setup.py. It needs to declare a package:

from distutils.core import setup

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

But this setup.py must be in the parent directory of the credentials package, so in the end, the directory structure is:

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

With this change, the module is found after reinstalling the package.

This could also be caused by two Python installs (but wasn't in my case), and @Mr_and_Mrs_D gives an answer for that case.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda