2016-12-25 48 views
0

情況:嘗試導入BeautifulSoup,但說我想對Python下運行的Python版本2美麗的湯的3

  • 安裝Python3
  • 安裝PyCharm
  • 更新PIP到V9
  • 更新setuptools的以V32
  • 安裝BeautifulSoup4

回溯(最近通話最後一個):在Python3當我運行from bs4 import beautifulsoup我與迴應 文件 「」,1號線,在 文件「/Users/stevendiffey/.Trash/3.6/beautifulsoup4 -4.5.1/bs4/init .py「,第53行 '您正試圖運行Python 3下的Beautiful Soup的Python 2版本。 這不會起作用。 '您需要轉換代碼,或者通過安裝代碼 (python setup.py install)或運行2to3(2to3 -w bs4)。「

我是全新的Python,已經找到了解決方案,但無濟於事。

如果有人可以幫助,這將是一個聖誕請客:)

+0

是Pycharm運行Python的2? –

+0

我相信如此。 項目翻譯:3.6.0 –

回答

1

原來這只是一個需要用正確的上限和替換:

from bs4 import beautifulsoup 

有:

from bs4 import BeautifulSoup 
0

你的錯誤應該是

/Python3.6/Lib/site-packages/bs4/ini t.py是PY2兼容模塊

/用戶/ stevendiffey/.Trash /3.6/beautifulsoup4-4.5.1/bs4/init.py

確保你正在運行/Python3.6/python.exe

嘗試

進口SYS

因爲我在sys.pat H:

print(i) 

確保/Python3.6/Lib/site-packages上游