如何在Windows上安装Python包?

2024-03-28 11:43:18 发布

您现在位置:Python中文网/ 问答频道 /正文

我很难设置python包。来自SetupTools的EasyInstall应该会有帮助,但它们没有Python 2.6的可执行文件。

例如,要安装Mechanize,我只需要根据install.txt将Mechanize文件夹放在C:\Python24\Lib\site包中,但是运行测试不起作用。有人能帮我解释一下吗?谢谢!


Tags: installtxt文件夹可执行文件libsitesetuptoolsmechanize
3条回答

This是如何在windows上获得easy_install的好教程。简单的答案是:在路径中添加C:\Python26\Scripts(或安装的任何python)。

accepted answer已经过时。所以首先,^{}easy_install,(Why use pip over easy_install?)更受欢迎。然后按照以下步骤在Windows上安装pip,这非常简单。

  1. 安装^{}

    curl https://bootstrap.pypa.io/ez_setup.py | python
    
  2. 安装^{}

    curl https://bootstrap.pypa.io/get-pip.py | python
    
  3. 也可以将路径添加到环境中,以便可以在任何地方使用pip。它就在C:\Python33\Scripts这样的地方。

较新版本的Python for Windows附带了pip包管理器。(source)

pip is already installed if you're using Python 2 >=2.7.9 or Python 3 >=3.4

使用它安装软件包:

cd C:\Python\Scripts\
pip.exe install <package-name>

所以你的情况是:

pip.exe install mechanize

相关问题 更多 >