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.

--target doesn't work for namespace packages

See original GitHub issue

When doing a local install of a namespace package, the .pth file doesn’t get picked up for some reason:

MAC-C08182:projects c08182$ mkdir targettest
MAC-C08182:projects c08182$ cd targettest/
MAC-C08182:targettest c08182$ pip install repoze.lru -t lib/
Downloading/unpacking repoze.lru
  Downloading repoze.lru-0.6.tar.gz
  Running setup.py (path:/private/var/folders/9w/_wt1czb57k9c5b0hgg6dfl2x7jbl85/T/pip_build_c08182/repoze.lru/setup.py) egg_info for package repoze.lru

Installing collected packages: repoze.lru
  Running setup.py install for repoze.lru

    Skipping installation of /var/folders/9w/_wt1czb57k9c5b0hgg6dfl2x7jbl85/T/tmp7uY1G8/lib/python/repoze/__init__.py (namespace package)
    Installing /var/folders/9w/_wt1czb57k9c5b0hgg6dfl2x7jbl85/T/tmp7uY1G8/lib/python/repoze.lru-0.6-py2.7-nspkg.pth
Successfully installed repoze.lru
Cleaning up...
MAC-C08182:targettest c08182$ PYTHONPATH=$(pwd)/lib
MAC-C08182:targettest c08182$ python
Python 2.7.7 |Anaconda 2.0.0 (x86_64)| (default, Jun  2 2014, 12:48:16) 
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://binstar.org
>>> import repoze.lru
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named repoze.lru
>>> 
MAC-C08182:targettest c08182$ 

However, all necessary files are in fact installed in lib/:

MAC-C08182:targettest c08182$ cd lib/
MAC-C08182:lib c08182$ ls
repoze              repoze.lru-0.6-py2.7.egg-info
repoze.lru-0.6-py2.7-nspkg.pth
MAC-C08182:lib c08182$ 

And of course the whole procedure works just fine for non-namespace packages.

Thanks to @mmerickel for setting me straight on the source of the issue.

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:23 (10 by maintainers)

github_iconTop GitHub Comments

3reactions
webmavencommented, Jul 17, 2014

@Ivoz site.addsitedir('lib') was exactly what I needed. Thanks!

1reaction
jaracocommented, Nov 12, 2017

@JensTimmerman That’s an interesting idea. I agree, it’s a bit hostile to install packages into a --target and then they not be viable without some additional steps.

I’m not sure a warning is quite appropriate - as it may be the case that a tool invoking pip will be correcting for the condition as rwt does.

More importantly, though, this issue largely goes away with Python 3.3, so perhaps the best solution is just to work around it until you can port everything to Python 3.

Read more comments on GitHub >

github_iconTop Results From Across the Web

python - `pip install -t` doesn't work with namespace packages
When I install requests with either --target or --prefix and add it to the PYTHONPATH I can import it just fine. But with...
Read more >
Managing namespaces - IBM Cloud Docs
To view your current region and resource group, run ibmcloud target . To set your region and resource group to a different choice,...
Read more >
Target Namespace - an overview | ScienceDirect Topics
An import relationship is used to bring an element or collection of elements belonging to a source package into another namespace, called the...
Read more >
multiprocessing — Process-based parallelism — Python 3.11 ...
This module does not work or is not available on WebAssembly platforms ... multiprocessing is a package that supports spawning processes using an...
Read more >
Troubleshoot known issues - .NET MAUI - Microsoft Learn
Templates are missing · ERROR Platform version is not present. · The WINDOWS #if directive is broken · ERROR Type or namespace 'Default'...
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