Different order in sys.path list after importing pkg_resources
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 2.9k
- Forks
- 1.4k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 1
Description
Hi,
I was having problems importing a module with ipython when I noticed that the output of sys.path is different whether is called from ipython or python. And the problem in ipython appears after importing pkg_resources by path module (ipython: __init__.py <-- embed.py <-- Ipython.core.interactiveshell <-- pickleshare <-- path <-- pkg-resources).
Running with setuptools 20.6.7 installed with conda 4.0.5 from its default channel:
#!/usr/bin/env python
import sys
print(sys.path)
import pkg_resources
print(sys.path)
this is what I get:
['', '/home/diego/Myusr/src/MyGitHub/AquaLab', '/home/diego/Myusr/src/MyGitHub/MyLab', '/home/diego/Myopt/anaconda2/envs/mylab3/lib/python35.zip', '/home/diego/Myopt/anaconda2/envs/mylab3/lib/python3.5', '/home/diego/Myopt/anaconda2/envs/mylab3/lib/python3.5/plat-linux', '/home/diego/Myopt/anaconda2/envs/mylab3/lib/python3.5/lib-dynload', '/home/diego/Myopt/anaconda2/envs/mylab3/lib/python3.5/site-packages', '/home/diego/Myopt/anaconda2/envs/mylab3/lib/python3.5/site-packages/PROPKA-3.1-py3.5.egg', '/home/diego/Myopt/anaconda2/envs/mylab3/lib/python3.5/site-packages/Sphinx-1.3.5-py3.5.egg', '/home/diego/Myopt/anaconda2/envs/mylab3/lib/python3.5/site-packages/openbabel-1.8.3-py3.5-linux-x86_64.egg', '/home/diego/Myopt/anaconda2/envs/mylab3/lib/python3.5/site-packages/pyEMMA-2.1-py3.5-linux-x86_64.egg', '/home/diego/Myopt/anaconda2/envs/mylab3/lib/python3.5/site-packages/setuptools-20.6.7-py3.5.egg']
['', '/home/diego/Myusr/src/MyGitHub/AquaLab', '/home/diego/Myusr/src/MyGitHub/MyLab', '/home/diego/Myopt/anaconda2/envs/mylab3/lib/python35.zip', '/home/diego/Myopt/anaconda2/envs/mylab3/lib/python3.5', '/home/diego/Myopt/anaconda2/envs/mylab3/lib/python3.5/plat-linux', '/home/diego/Myopt/anaconda2/envs/mylab3/lib/python3.5/lib-dynload', '/home/diego/Myopt/anaconda2/envs/mylab3/lib/python3.5/site-packages/PROPKA-3.1-py3.5.egg', '/home/diego/Myopt/anaconda2/envs/mylab3/lib/python3.5/site-packages/Sphinx-1.3.5-py3.5.egg', '/home/diego/Myopt/anaconda2/envs/mylab3/lib/python3.5/site-packages/openbabel-1.8.3-py3.5-linux-x86_64.egg', '/home/diego/Myopt/anaconda2/envs/mylab3/lib/python3.5/site-packages/pyEMMA-2.1-py3.5-linux-x86_64.egg', '/home/diego/Myopt/anaconda2/envs/mylab3/lib/python3.5/site-packages/setuptools-20.6.7-py3.5.egg', '/home/diego/Myopt/anaconda2/envs/mylab3/lib/python3.5/site-packages']
Before importing pkg_resources the path /.../site-packages appears before any /.../site-packages/*.egg.
After importing pkg_resources the path /.../site-packages appears after every /.../site-packages/*.egg affecting the way they are imported. Example:
#!/usr/bin/env python
import sys
import pybel
print(sys.path)
print(pybel.__spec__)
['', '/home/diego/Myusr/src/MyGitHub/AquaLab', '/home/diego/Myusr/src/MyGitHub/MyLab', '/home/diego/Myopt/anaconda2/envs/mylab3/lib/python35.zip', '/home/diego/Myopt/anaconda2/envs/mylab3/lib/python3.5', '/home/diego/Myopt/anaconda2/envs/mylab3/lib/python3.5/plat-linux', '/home/diego/Myopt/anaconda2/envs/mylab3/lib/python3.5/lib-dynload', '/home/diego/Myopt/anaconda2/envs/mylab3/lib/python3.5/site-packages', '/home/diego/Myopt/anaconda2/envs/mylab3/lib/python3.5/site-packages/PROPKA-3.1-py3.5.egg', '/home/diego/Myopt/anaconda2/envs/mylab3/lib/python3.5/site-packages/Sphinx-1.3.5-py3.5.egg', '/home/diego/Myopt/anaconda2/envs/mylab3/lib/python3.5/site-packages/openbabel-1.8.3-py3.5-linux-x86_64.egg', '/home/diego/Myopt/anaconda2/envs/mylab3/lib/python3.5/site-packages/pyEMMA-2.1-py3.5-linux-x86_64.egg', '/home/diego/Myopt/anaconda2/envs/mylab3/lib/python3.5/site-packages/setuptools-20.6.7-py3.5.egg']
ModuleSpec(name='pybel', loader=<_frozen_importlib_external.SourceFileLoader object at 0x7f6bee5169b0>, origin='/home/diego/Myopt/anaconda2/envs/mylab3/lib/python3.5/site-packages/pybel.py')
And
#!/usr/bin/env python
import sys
import pkg_resources
import pybel
print(sys.path)
print(pybel.__spec__)
['', '/home/diego/Myusr/src/MyGitHub/AquaLab', '/home/diego/Myusr/src/MyGitHub/MyLab', '/home/diego/Myopt/anaconda2/envs/mylab3/lib/python35.zip', '/home/diego/Myopt/anaconda2/envs/mylab3/lib/python3.5', '/home/diego/Myopt/anaconda2/envs/mylab3/lib/python3.5/plat-linux', '/home/diego/Myopt/anaconda2/envs/mylab3/lib/python3.5/lib-dynload', '/home/diego/Myopt/anaconda2/envs/mylab3/lib/python3.5/site-packages/PROPKA-3.1-py3.5.egg', '/home/diego/Myopt/anaconda2/envs/mylab3/lib/python3.5/site-packages/Sphinx-1.3.5-py3.5.egg', '/home/diego/Myopt/anaconda2/envs/mylab3/lib/python3.5/site-packages/openbabel-1.8.3-py3.5-linux-x86_64.egg', '/home/diego/Myopt/anaconda2/envs/mylab3/lib/python3.5/site-packages/pyEMMA-2.1-py3.5-linux-x86_64.egg', '/home/diego/Myopt/anaconda2/envs/mylab3/lib/python3.5/site-packages/setuptools-20.6.7-py3.5.egg', '/home/diego/Myopt/anaconda2/envs/mylab3/lib/python3.5/site-packages']
ModuleSpec(name='pybel', loader=<zipimporter object "/home/diego/Myopt/anaconda2/envs/mylab3/lib/python3.5/site-packages/openbabel-1.8.3-py3.5-linux-x86_64.egg">, origin='/home/diego/Myopt/anaconda2/envs/mylab3/lib/python3.5/site-packages/openbabel-1.8.3-py3.5-linux-x86_64.egg/pybel.py')
Which at the end means pybel does not work properly under ipython.
Why is this?
Is this solved with setuptools 20.6.8?
Is this a problem a bug in the way conda installs setuptool 20.6.7?
Can anyone reproduce this problem with conda 4.0.5?
conda create --name test python=3
source activate test
conda install -c https://conda.anaconda.org/omnia openbabel
conda install ipython
Thanks
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the supplied minimal Python script and the conda reproduction to compare sys.path before and after importing pkg_resources. Then trace the pkg_resources import path and its interaction with the egg entries, using the pybel examples to verify the effect. Done means determining whether setuptools or conda causes the reorder and documenting a reproducible resolution.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100