[Python-modules-team] Bug#832626: python-requests: Importing the module fails

Daniele Tricoli eriol at mornie.org
Thu Jul 28 14:00:56 UTC 2016


Hello Michel,
thanks for the additional details.

On Thursday, July 28, 2016 02:29:25 PM Michel Le Bihan wrote:
> >>> sys.path
> 
> ['', '/usr/local/lib/python2.7/dist-packages/pytvmaze-1.4.3-py2.7.egg',
> '/usr/local/lib/python2.7/dist-packages/pyScss-1.3.4-py2.7-linux-x86_64.egg'
> , '/usr/local/lib/python2.7/dist-packages/pyparsing-2.0.7-py2.7.egg',
> '/usr/local/lib/python2.7/dist-packages/Flask_Login-0.3.2-py2.7.egg',
> '/usr/local/lib/python2.7/dist-packages/Flask_Compress-1.3.0-py2.7.egg',
> '/usr/local/lib/python2.7/dist-packages/cssmin-0.2.0-py2.7.egg',
> '/usr/local/lib/python2.7/dist-packages/Flask_Assets-0.11-py2.7.egg',
> '/usr/local/lib/python2.7/dist-packages/CherryPy-4.0.0-py2.7.egg',
> '/usr/local/lib/python2.7/dist-packages/flask_restplus-0.7.2-py2.7.egg',
> '/usr/local/lib/python2.7/dist-packages/ordereddict-1.1-py2.7.egg',
> '/usr/local/lib/python2.7/dist-packages/Flask_RESTful-0.3.5-py2.7.egg',
> '/usr/local/lib/python2.7/dist-packages/Flask-0.10.1-py2.7.egg',
> '/usr/local/lib/python2.7/dist-packages/APScheduler-3.0.5-py2.7.egg',
> '/usr/local/lib/python2.7/dist-packages/guessit-0.10.3-py2.7.egg',
> '/usr/local/lib/python2.7/dist-packages/path.py-8.1.2-py2.7.egg',
> '/usr/local/lib/python2.7/dist-packages/tmdb3-0.7.2-py2.7.egg',
> '/usr/local/lib/python2.7/dist-packages/python_dateutil-2.4.2-py2.7.egg',
> '/usr/local/lib/python2.7/dist-packages/rpyc-3.3.0-py2.7.egg',
> '/usr/local/lib/python2.7/dist-packages/progressbar-2.3-py2.7.egg',
> '/usr/local/lib/python2.7/dist-packages/pynzb-0.1.0-py2.7.egg',
> '/usr/local/lib/python2.7/dist-packages/PyRSS2Gen-1.1-py2.7.egg',
> '/usr/local/lib/python2.7/dist-packages/PyYAML-3.11-py2.7-linux-x86_64.egg',
> '/usr/local/lib/python2.7/dist-packages/SQLAlchemy-1.0.11-py2.7-linux-
> x86_64.egg', '/usr/local/lib/python2.7/dist-
> packages/feedparser-5.2.1-py2.7.egg', '/usr/local/lib/python2.7/dist-
> packages/pathlib-1.0.1-py2.7.egg', '/usr/local/lib/python2.7/dist-
> packages/webassets-0.11.1-py2.7.egg', '/usr/local/lib/python2.7/dist-
> packages/pytz-2015.7-py2.7.egg', '/usr/local/lib/python2.7/dist-
> packages/aniso8601-1.1.0-py2.7.egg', '/usr/local/lib/python2.7/dist-
> packages/itsdangerous-0.24-py2.7.egg', '/usr/local/lib/python2.7/dist-
> packages/Werkzeug-0.11.3-py2.7.egg', '/usr/local/lib/python2.7/dist-
> packages/futures-3.0.3-py2.7.egg', '/usr/local/lib/python2.7/dist-
> packages/tzlocal-1.2-py2.7.egg', '/usr/local/lib/python2.7/dist-
> packages/stevedore-1.10.0-py2.7.egg', '/usr/local/lib/python2.7/dist-
> packages/babelfish-0.5.5-py2.7.egg', '/usr/local/lib/python2.7/dist-
> packages/urllib3-1.12-py2.7.egg', '/usr/local/lib/python2.7/dist-
> packages/plumbum-1.6.1.post0-py2.7.egg', '/usr/lib/python2.7',
> '/usr/lib/python2.7/plat-x86_64-linux-gnu', '/usr/lib/python2.7/lib-tk',
> '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload',
> '/usr/local/lib/python2.7/dist-packages',
> '/usr/lib/python2.7/dist-packages',
> '/usr/lib/python2.7/dist-packages/PILcompat', '/usr/lib/python2.7/dist-
> packages/gtk-2.0', '/usr/lib/pymodules/python2.7',
> '/usr/lib/python2.7/dist- packages/wx-3.0-gtk2']

OK, the problem is due to several /usr/local/lib/python2.7/dist-packages/
before /usr/lib/python2.7/dist-packages (where system package
modules are installed).
I suppose you had to install manually something, but the problem is
that mixing system package with manually installed packages can lead to
situation like the one you discovered.

If you tell Python to ignore site-specific configuration hook, you should
be able to confirm this. Just call python with -S.

For example:
python -S -c "import sys; sys.path.append('/usr/lib/python2.7/dist-packages/'); import requests; print requests.__version__"
2.10.0

Note that you have to explicitly add '/usr/lib/python2.7/dist-packages/' to
sys.path.

So, to solve the problem you should get rid of the local installed packages
that lead to this situation, but since it can be tricky to find packages who
meddle with system packaged ones, it would better (and easier) to just remove
all of them (manually installed I mean) and use, for example, a virtualenv for
packages not in Debian, to not have to worry about mixing packages from different
source.

HTH, 

-- 
 Daniele Tricoli 'eriol'
 https://mornie.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.alioth.debian.org/pipermail/python-modules-team/attachments/20160728/57b3c5e9/attachment.sig>


More information about the Python-modules-team mailing list