2016-09-11 9 views
0

beautifulsoup4モジュールをpython2.7にインストールしましたが、インポートに失敗しています。Mac OSでのインポート時にPythonモジュールがインストールされる

このディレクトリの下にpythonモジュールがインストールされています。

$ls -l /Library/Python/2.7/site-packages 
total 1080 
-rw-r--r-- 1 root wheel  119 Aug 22 2015 README 
drwxr-xr-x 9 root wheel  306 Sep 8 22:17 beautifulsoup4-4.5.1.dist-info 
drwxr-xr-x 14 root wheel  476 Sep 8 22:17 bs4 
-rw-r--r-- 1 root wheel  30 Sep 8 22:03 easy-install.pth 
drwxr-xr-x 34 root wheel 1156 Sep 8 22:16 pip 
drwxr-xr-x 10 root wheel  340 Sep 8 22:16 pip-8.1.2.dist-info 
-rw-r--r-- 1 root wheel 538338 Sep 8 22:03 setuptools-26.1.1-py2.7.egg 
-rw-r--r-- 1 root wheel  30 Sep 8 22:03 setuptools.pth 
drwxr-xr-x 6 root wheel  204 Jul 26 21:13 vboxapi 
-rw-r--r-- 1 root wheel  241 Jul 26 21:13 vboxapi-1.0-py2.7.egg-info 
drwxr-xr-x 32 root wheel 1088 Sep 8 22:16 wheel 
drwxr-xr-x 11 root wheel  374 Sep 8 22:16 wheel-0.29.0.dist-info 
$ 

pythonシェルの出力が失敗します。私はpython2.7を使用しています

$ /usr/bin/python 
Python 2.7.10 (default, Oct 23 2015, 19:19:21) 
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)] on darwin 
Type "help", "copyright", "credits" or "license" for more information. 
>>> import beautifulsoup4 
Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
ImportError: No module named beautifulsoup4 
>>> exit() 

のpython sys.pathは、モジュールのインポートが失敗する理由を提案してください/Library/Python/2.7/site-packages

$ /usr/bin/python 
Python 2.7.10 (default, Oct 23 2015, 19:19:21) 
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)] on darwin 
Type "help", "copyright", "credits" or "license" for more information. 
>>> import sys 
>>> print "\n".join(sys.path) 
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip 
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7 
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin 
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac 
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages 
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python 
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk 
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old 
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload 
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC 
/Library/Python/2.7/site-packages 
/Library/Python/2.7/site-packages/setuptools-26.1.1-py2.7.egg 
>>> exit() 
$ 

としてモジュールの場所を持っています。モジュールがbs4呼ばれ

おかげ

+0

あなたはターミナルでeasy_installをBeautifulSoupを使用してみましたが?更新してもう一度実行してください。また:bs4から輸入BeautifulSoup –

答えて

0

は、ないbeautifulsoup4、と試してみてください。

import bs4 
+0

それは働いた。ありがとう、 – bobby

0

はこれを試してみてください:

from bs4 import BeautifulSoup 
+0

それは働いた。ありがとう、 – bobby

関連する問題