Python 安装库无法安装

发布于 2024-10-06 18:10:47 字数 480 浏览 2 评论 0原文

我使用的是 Windows XP。

我已经按照此处的建议下载了 Python 2.7。我单击了 .msi 链接,它安装得很好。现在,我想使用 beautifulsoup。我下载的是3.2.0版本。

我不知道把它放在哪里或如何安装。我将其放入 ac:\temp 文件夹中,然后双击 setup.py,它执行了某些操作,但我的测试文件不起作用。

import urllib2
from BeautifulSoup import BeautifulSoup

page = urllib2.urlopen("http://www.google.com")
soup = BeautifulSoup(page)
print soup.prettify()

我做错了什么? 我也尝试使用命令行进行安装,正如它所说的那样,但这只会带来更多有关 python 未被识别的错误。普通的 python 脚本可以正常工作。只是我不知道如何使用这个库来安装它。请帮忙!

I am on Windows XP.

I have downloaded Python 2.7 as per the recommendations here. I clicked the .msi link and it installed fine. Now, I want to use beautifulsoup. I have downloaded version 3.2.0.

I have no idea where to put it or how to install it. I put it into a c:\temp folder and double clicked on setup.py and it does something but my test file does not work.

import urllib2
from BeautifulSoup import BeautifulSoup

page = urllib2.urlopen("http://www.google.com")
soup = BeautifulSoup(page)
print soup.prettify()

What am I doing wrong?
I tried to install using the command line too as it said, but that just gives more errors about python not being recognised. Normal python script works fine. Just I have no idea what to do with this library to install it. Please help!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

£烟消云散 2024-10-13 18:10:47

不要双击 setup.py 。打开命令,然后导航到 setup.py 所在的文件夹。然后运行:

python setup.py install

之后,尝试import BeautifulSoup。如果有效的话,一切都好。

Don't double click on setup.py . Open command and then navigate to the folder where setup.py is. Then run:

python setup.py install

After that, try import BeautifulSoup. If it works, all is well.

燃情 2024-10-13 18:10:47

Python 的问题不在于编程复杂性,而在于分布复杂性。
如果您使用更好的发行版,例如 ActivePython(卸载当前发行版并安装此发行版),那就更好了:

http:// www.activestate.com/activepython/downloads

此发行版与官方发行版之间的区别在于,它修改了 PATH 环境变量,因此可以访问 Python 可执行文件,并且您的:

python setup.py install

...无论您身在何处,都可以工作。

当然,另一种可能性是手动修改 PATH 变量以包含 Python 发行版的 bin 目录。对此进行了解释:

http://www.computerhope.com/issues/ch000549.htm

The problem with Python is not about programming complexity, but distribution complexity.
Better if you use a better distribution, such as ActivePython (uninstall current one and install this one):

http://www.activestate.com/activepython/downloads

The difference between this distribution and the official one is that this modifies the PATH environment variable, so the Python executable will be reachable, and your:

python setup.py install

... will work, wherever you are.

Another possibility, of course, is to manually modify your PATH variable to include the bin directory of your Python distribution. This is explained here:

http://www.computerhope.com/issues/ch000549.htm

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文