python feedparser ImportError: No module named feedparser
Je reçois une erreur lorsque je tente d'inclure le feedparser bibliothèque dans la interactif Python environnement:
>>>> import feedparser
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named feedparser
Cela arrive aussi avec BeautifulSoup et pydelicious. Pourquoi j'obtiens cette erreur?
L'aide de mac OS X 10.8.3, qui incluent les fichiers suivants dans le répertoire /usr/bin:
$ ll python*
-rwxr-xr-x 2 root wheel 58896 Mar 17 20:55 python
-rwxr-xr-x 6 root wheel 925 Nov 16 10:30 python-config
lrwxr-xr-x 1 root wheel 75 Nov 16 10:30 python2.5 -> ../../System/Library/Frameworks/Python.framework/Versions/2.5/bin/python2.5
lrwxr-xr-x 1 root wheel 82 Nov 16 10:30 python2.5-config -> ../../System/Library/Frameworks/Python.framework/Versions/2.5/bin/python2.5-config
lrwxr-xr-x 1 root wheel 75 Nov 16 10:30 python2.6 -> ../../System/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6
lrwxr-xr-x 1 root wheel 82 Nov 16 10:30 python2.6-config -> ../../System/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6-config
lrwxr-xr-x 1 root wheel 75 Nov 16 10:30 python2.7 -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7
lrwxr-xr-x 1 root wheel 82 Nov 16 10:30 python2.7-config -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7-config
-rwxr-xr-x 2 root wheel 58896 Mar 17 20:55 pythonw
lrwxr-xr-x 1 root wheel 76 Nov 16 10:30 pythonw2.5 -> ../../System/Library/Frameworks/Python.framework/Versions/2.5/bin/pythonw2.5
lrwxr-xr-x 1 root wheel 76 Nov 16 10:30 pythonw2.6 -> ../../System/Library/Frameworks/Python.framework/Versions/2.6/bin/pythonw2.6
lrwxr-xr-x 1 root wheel 76 Nov 16 10:30 pythonw2.7 -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/pythonw2.7
Python emplacement:
$ which python
/usr/bin/python
Python version:
$ python -V
Python 2.7.2
Il est probablement inutile, mais j'ai installé Python avec Homebrew:
$ brew install python
Qui a installé ces fichiers:
$ brew list python
/usr/local/Cellar/python/2.7.4/bin/smtpd2.py
/usr/local/Cellar/python/2.7.4/bin/smtpd2.7.py
/usr/local/Cellar/python/2.7.4/bin/smtpd.py
/usr/local/Cellar/python/2.7.4/bin/pythonw2.7
/usr/local/Cellar/python/2.7.4/bin/pythonw2
/usr/local/Cellar/python/2.7.4/bin/pythonw
/usr/local/Cellar/python/2.7.4/bin/python2.7-config
/usr/local/Cellar/python/2.7.4/bin/python2.7
/usr/local/Cellar/python/2.7.4/bin/python2-config
/usr/local/Cellar/python/2.7.4/bin/python2
/usr/local/Cellar/python/2.7.4/bin/python-config
/usr/local/Cellar/python/2.7.4/bin/python
/usr/local/Cellar/python/2.7.4/bin/pydoc2.7
/usr/local/Cellar/python/2.7.4/bin/pydoc2
/usr/local/Cellar/python/2.7.4/bin/pydoc
/usr/local/Cellar/python/2.7.4/bin/pip-2.7
/usr/local/Cellar/python/2.7.4/bin/pip
/usr/local/Cellar/python/2.7.4/bin/idle2.7
/usr/local/Cellar/python/2.7.4/bin/idle2
/usr/local/Cellar/python/2.7.4/bin/idle
/usr/local/Cellar/python/2.7.4/bin/easy_install-2.7
/usr/local/Cellar/python/2.7.4/bin/easy_install
/usr/local/Cellar/python/2.7.4/bin/2to3-2.7
/usr/local/Cellar/python/2.7.4/bin/2to3-2
/usr/local/Cellar/python/2.7.4/bin/2to3
/usr/local/Cellar/python/2.7.4/Build Applet.app/Contents/ (8 files)
/usr/local/Cellar/python/2.7.4/Frameworks/Python.framework/ (4858 files)
/usr/local/Cellar/python/2.7.4/IDLE.app/Contents/ (8 files)
/usr/local/Cellar/python/2.7.4/Python Launcher.app/Contents/ (17 files)
/usr/local/Cellar/python/2.7.4/share/man/ (3 files)
/usr/local/Cellar/python/2.7.4/share/python/ (317 files)
Puis j'ai installé feedparser:
$ pip install feedparser
Qui a mené à ces fichiers:
$ ll /usr/local/lib/python2.7/site-packages/f*
-rw-r--r-- 1 foobar admin 166583 Apr 24 20:16 /usr/local/lib/python2.7/site-packages/feedparser.py
-rw-r--r-- 1 foobar admin 138040 Apr 24 20:16 /usr/local/lib/python2.7/site-packages/feedparser.pyc
J'espérais éviter ces sortes de problèmes à l'aide des Homebrew (qui a bien fonctionné avec d'autres bibliothèques). Ce qui me manque?
Les problèmes de configuration qui suivent inévitablement une installation manuelle des paquets (par opposition à un gestionnaire de paquets).
ensuite, utilisez virtualenv
double possible de python homebrew par défaut
ensuite, utilisez virtualenv
double possible de python homebrew par défaut
OriginalL'auteur craig | 2013-04-30
Vous devez vous connecter pour publier un commentaire.
Si votre Python est à
/usr/bin/python
, alors vous n'êtes pas à l'aide de l'Homebrew-construit Python, mais l'OS X par défaut. (Notez aussi le numéro de version des divergences dans votre sortie.) Donc, tout colis que vous installez avecpip
sera installé dans le Homebrew de l'espace, mais ne sera pas visible à l'OS X fourni d'installation de Python. (OS X ne fournit paspip
, donc c'est tout à fait comme les Homebrew.)Le correctif pour vous est tout à fait susceptibles de mettre à jour votre chemin pour avoir
/usr/local/bin
venir avant/usr/bin
.OriginalL'auteur Peter Eisentraut