question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

pip install --editable does not work as expected for namespace packages

See original GitHub issue

Environment

  • pip version: pip 19.3.1
  • Python version: Python 3.6.8
  • OS: linux

Description This is not a duplicate of #3

I have a mainpackage that is a standard package with an __init__.py. It has a subpackage, mainpackage.ext, that is a namespace package according to PEP 420 (no __init__.py). All of this is located in a main_package folder with a setup.py.

Now I have a separate folder some_plugin with another setup.py. This folder contains a plugin for mainpackage. It therefore has a package mainpackage.ext.someplugin with an __init__.py in mainpackage/ext/someplugin/ but not in mainpackage/ or mainpackage/ext/.

Using a normal pip install, this works as expected. But when using pip install -e to install both main_package and some_plugin, the plugin cannot actually be imported.

Expected behavior Same behavior between pip install and pip install -e, i.e. the ability to import mainpackage.ext.someplugin without a ModuleNotFoundError.

How to Reproduce I’ve created a repository with a minimal example: https://github.com/jonasrauber/python_namespace_packages_editable_bug

Works

sudo pip3 install main_package/
sudo pip3 install some_plugin/

python3 -c "import mainpackage; print(mainpackage.a)"
# -> hello

python3 -c "import mainpackage.ext.someplugin; print(mainpackage.ext.someplugin.a)"
# -> plugin

Fails

sudo pip3 install -e main_package/
sudo pip3 install -e some_plugin/

python3 -c "import mainpackage; print(mainpackage.a)"
# -> hello

python3 -c "import mainpackage.ext.someplugin; print(mainpackage.ext.someplugin.a)"
# -> ERROR

# Traceback (most recent call last):
#   File "<string>", line 1, in <module>
# ModuleNotFoundError: No module named 'mainpackage.ext.someplugin'

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
pfmoorecommented, Oct 28, 2019

Does the same behaviour happen if you use python setup.py develop rather than pip install -e? The editable install mechanism is implemented by setuptools, so I suspect this may be down to how setuptools handles PEP 420 namespace packages. Checking setup.py develop will help confirm this.

0reactions
no-response[bot]commented, Dec 16, 2019

This issue has been automatically closed because there has been no response to our request for more information from the original author. With only the information that is currently in the issue, we don’t have enough information to take action. Please reach out if you have or find the answers we need so that we can investigate further.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Namespace packages and pip install -e - Stack Overflow
Sometime I got into problem with importing my develop based package, it was reported as missing. Solution for now?
Read more >
Unresolved references to editable packages (pip install
In the project that is importing the changed package: Open the PyCharm Settings. In the Settings window: Go to Project Interpreter; Then update...
Read more >
Third try on editable installs - Packaging
So I took a look at flit. It has two kinds of editable installs. One uses symlinks to link the install into site-packages....
Read more >
Drop our use of namespace packages
If one library installed with pip install -e to enable “editable” mode, and another is installed without the -e option as a regular...
Read more >
Packages and Packaging - UW PCE : Python Certificate
The code will be run when the package is imported – just like a module. Modules inside packages are not automatically imported. So,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found