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$
从这里忽略
我删除了所有版本的 python macport 和系统并重新安装了 python 2.7 版本
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
>>>
,所有路径看起来也不错
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 同时安装了 Django
和 BeautifulSoup
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项目
它说它无法导入模块BeautifulSoup
请帮忙
谢谢
从下面忽略
我在我的 mac 上安装了 BeautifulSoup,我可以执行以下操作:
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
我该如何解决此问题
谢谢
Update
By adding BeautifulSoup.py to my app source, this error was gone :)
Thanks @Ned Deily, that took along time, but was fruitful
Ignore from here
I have just one instance of python 2.5 installed with BeautifulSoup, still no luck!, what I am I doing wrong, please help
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$
Ignore from here
I removed all versions of python from macport and system and re installed the python 2.7 version
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
>>>
and all the paths also look good
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
and have just one version of python that has both Django
and BeautifulSoup
installed
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$
but still when I run dev_appserver.py project
it says it can not import module BeautifulSoup
Please help
Thank you
Ignore from below
I have BeautifulSoup installed on my mac and I can do the following:
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
>>>
but when I run my djando app and try to run the code, it fails saying
Error was: No module named BeautifulSoup
It seems I am using everything correctly
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
How can I resolve this issue
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您显然已经安装了第二个更新的 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。尝试:
目前,您需要指定版本,因为当前有一个较新的 Beta 版 Beautiful Soup 4 似乎与 Python 2.5 不兼容。
更新:您似乎还安装了多个版本的 Python 2.5。您显示的路径适用于第 3 方 Python,而不是 Apple 提供的 Python 2.5。 所以我的最后建议是尝试对 Apple 提供的 Python 2.5 使用 easy_install-2.5:
You apparently have installed a second, newer instance of Python 2.6. Chances are that your Django app is installed and being run from another instance of Python 2.6, possibly the system Python 2.6 (
/usr/bin/python
or/usr/bin/python2.6
). Typewhich python
to see the path of the Python which has BeautifulSoup (/usr/local/bin/python
perhaps?). You'll need to consolidate things; either install BeautifulSoup in the Python with Django or install Django in the Python with BeautifulSoup.UPDATE: Since you are apparently running the Google App Engine dev_server, chances are that it is running under Python 2.5, not Python 2.6; at the moment, GAE is officially supported only with 2.5, as far as I know. Note Apple ships both a Python 2.6 and 2.5 with OS X 10.6. So you probably need to install Beautiful Soup in Python 2.5. Try:
At the moment, you'll need to specify the version as there is currently a newer beta version of Beautiful Soup 4 that appears to be incompatible with Python 2.5.
UPDATE: You also seem to have more than one version of Python 2.5 installed. The path you show is for a 3rd-party Python, not the Apple-supplied Python 2.5. So my final suggestion is to try using the easy_install-2.5 for the Apple-supplied Python 2.5: