2011-08-20 43 views
1

更新BeautifulSoup,但不承認當dev_appserver運行

By adding BeautifulSoup.py to my app source, this error was gone :) 

感謝@Ned Deily,沿着時間了,但富有成果

忽略從這裏
我剛纔一個與BeautifulSoup一起安裝的python 2.5實例,仍然沒有運氣!,我做錯了什麼,請幫助

bash-3.2$ ls -ltr /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages 
total 1096 
-rw-r--r-- 1 Harit admin 66866 May 28 2006 BeautifulSoup.py 
-rw-r--r-- 1 Harit admin 26413 May 28 2006 BeautifulSoupTests.py 
-rw-rwxr-- 1 root admin  119 Sep 18 2006 README 
drwxr-xr-x 19 Harit admin  646 Aug 20 23:58 django 
-rw-r--r-- 1 Harit admin 1228 Aug 20 23:58 Django-1.3-py2.5.egg-info 
-rw-r--r-- 1 Harit admin 333390 Aug 21 00:17 setuptools-0.6c11-py2.5.egg 
-rw-r--r-- 1 Harit admin  30 Aug 21 00:17 setuptools.pth 
-rw-r--r-- 1 Harit admin  215 Aug 21 00:22 easy-install.pth 
-rw-r--r-- 1 Harit admin 33196 Aug 21 00:23 BeautifulSoupTests.pyc 
-rw-r--r-- 1 Harit admin 67193 Aug 21 00:23 BeautifulSoup.pyc 
-rw-r--r-- 1 Harit admin  970 Aug 21 00:23 BeautifulSoup-3.0.0-py2.5.egg-info 
bash-3.2$ 

忽略從這裏

我刪除了蟒蛇的所有版本從macport和系統並重新安裝了蟒蛇

bash-3.2$ python 
Python 2.7.2 (v2.7.2:8527427914a2, Jun 11 2011, 15:22:34) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin 
Type "help", "copyright", "credits" or "license" for more information. 
>>> import django 
>>> from BeautifulSoup import BeautifulSoup 
>>> 

2.7版本和所有的路徑也好看

bash-3.2$ echo $PATH 
/Library/Frameworks/Python.framework/Versions/2.7/bin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/usr/X11/bin:/opt/local/bin 

並且只有一個版本的python小號都DjangoBeautifulSoup安裝

bash-3.2$ cd /Library/Frameworks/Python.framework/Versions/Current/ 
Headers/ Mac/  Python  Resources/ bin/  include/ lib/  share/  
bash-3.2$ cd /Library/Frameworks/Python.framework/Versions/Current/lib/python2.7/lib 
lib-dynload/ lib-tk/  lib2to3/  
bash-3.2$ cd /Library/Frameworks/Python.framework/Versions/Current/lib/python2.7/ 
Display all 641 possibilities? (y or n) 
bash-3.2$ ls /Library/Frameworks/Python.framework/Versions/Current/lib/python2.7/site-packages/ 
BeautifulSoup-3.2.0-py2.7.egg-info BeautifulSoupTests.pyc   easy-install.pth 
BeautifulSoup.py   Django-1.3-py2.7.egg-info  setuptools-0.6c11-py2.7.egg 
BeautifulSoup.pyc   README     setuptools.pth 
BeautifulSoupTests.py   django 
bash-3.2$ 

,但仍當我運行dev_appserver.py project它說,它無法導入模塊BeautifulSoup

請幫

謝謝

從下面忽略
我有美麗的lSoup安裝在我的MAC,我可以做到以下幾點:

bash-3.2$ python 
Python 2.6.7 (r267:88850, Jul 27 2011, 11:54:59) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin 
Type "help", "copyright", "credits" or "license" for more information. 
>>> from BeautifulSoup import BeautifulSoup 
>>> 

,但是當我跑我djando應用程序,並嘗試運行的代碼,它沒有說

Error was: No module named BeautifulSoup 

看來我正確地使用一切

bash-3.2$ which python 
/opt/local/bin/python 

lrwxr-xr-x 1 root admin  9 Aug 16 13:55 python -> python2.6 

bash-3.2$ cd /Library/Python/2.6/site-packages/ 
BeautifulSoup-3.0.0-py2.6.egg-info     ipython-0.11-py2.6.egg/ 
BeautifulSoup.py         mercurial/ 
BeautifulSoup.pyc         mercurial-1.8.3_20110502-py2.6.egg-info/ 
BeautifulSoupTests.py        nose-1.1.2-py2.6.egg/ 
BeautifulSoupTests.pyc        paramiko-1.7.6-py2.6.egg 
Django-1.3-py2.6.egg-info       pip-1.0.2-py2.6.egg/ 
MySQL_python-1.2.3-py2.6-macosx-10.6-universal.egg pycrypto-2.3-py2.6-macosx-10.6-universal.egg 
README            pysqlite-2.6.3-py2.6.egg-info 
django/            pysqlite2/ 
easy-install.pth         setuptools-0.6c11-py2.6.egg 
easy_install          setuptools.pth 
easy_install-2.6         xlrd/ 
hgext/            xlrd-0.6.1-py2.6.egg-info 

我怎樣才能解決這個問題
感謝

回答

4

你顯然已經安裝了第二個較新的Python 2.6實例。很有可能您的Django應用程序已安裝並正在從Python 2.6的另一個實例(可能是系統Python 2.6(/usr/bin/python/usr/bin/python2.6))運行。鍵入which python以查看具有BeautifulSoup的Python的路徑(/usr/local/bin/python也許?)。你需要鞏固東西;或者使用Django在Python中安裝BeautifulSoup,或者使用BeautifulSoup在Python中安裝Django。

更新:由於您顯然正在運行Google App Engine dev_server,因此它有可能在Python 2.5下運行,而不是Python 2.6;就目前而言,據我所知,GAE僅得到2.5的正式支持。注意Apple帶有OS X 10.6的Python 2.6和2.5。所以你可能需要在Python 2.5中安裝Beautiful Soup。嘗試:

easy_install-2.5 -U -v beautifulsoup==3.2 

此刻,你需要,因爲目前美麗的湯4的更新測試版,似乎是不符合Python 2.5的指定版本。

更新:您似乎還安裝了多個版本的Python 2.5。您展示的路徑是針對第三方Python,而不是Apple提供的Python 2.5。 所以我的最後一個建議是使用的easy_install - 2.5爲提供​​的蘋果Python 2.5的嘗試:

/usr/bin/easy_install-2.5 -U -v beautifulsoup==3.2 
+0

更新我的發現,仍然沒有工作:( – daydreamer

+0

但你的發現證實了德說什麼'/。 opt/local/bin/python'不是標準安裝 - 看起來像MacPorts安裝的那個,它有自己的'site-packages'目錄,你顯示的目錄是Python系統 –

+0

我是一個新手,你可以告訴我如何解決這個問題嗎?卸載Python表單macports? – daydreamer