我很难设置 python 包。轻松安装自 设置工具 应该会有所帮助,但他们没有 Python 2.6 的可执行文件。

例如,要安装 Mechanize,我只是应该根据 INSTALL.txt 将 Mechanize 文件夹放在 C:\Python24\Lib\site-packages 中,但运行测试不起作用。有人可以帮助阐明这一点吗?谢谢!

有帮助吗?

解决方案

接受的答案 已经过时了。所以首先, pip 优先于 easy_install, (为什么使用 pip 而不是 easy_install?)。然后按照以下步骤进行安装 pip 在 Windows 上,这非常简单。

  1. 安装 setuptools:

    curl https://bootstrap.pypa.io/ez_setup.py | python
    
  2. 安装 pip:

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

其他提示

对于Windows

较新版本的Python附带的 PIP 的包管理器。 (源)

  

如果您使用的Python 2 PIP已经安装> = 2.7.9或Python 3> = 3.4

使用,要安装软件包:

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

所以你的情况这会是:

pip.exe install mechanize

是一个关于如何获取的很好的教程 easy_install 在窗户上。简短的回答:添加 C:\Python26\Scripts (或者你安装的任何Python)到你的路径。

您不需要为setuptools的可执行文件。 你可以下载源代码,解压缩,遍历到下载的目录,并运行在命令提示python setup.py install

与Python 2.7开始,PIP默认情况下包含。简单地通过

下载你所需的包装
python -m pip install [package-name]

正如我写别处

  

包装在Python是可怕的。根本原因在于语言没有船只的软件包管理器。

     

幸运的是,有用于Python一个包管理器,称为。皮普是Ruby的宝石启发,但缺少一些功能。讽刺的是,皮普本身就是安装复杂。上流行的64位Windows安装需要构建和从源代码安装这两个包。这是一个很大的要求,任何人新的节目。


所以,我们要做的正确的事是安装点子。但是,如果你不能打扰,克里斯托夫Gohlke提供二进制文件流行的Python包的所有Windows平台的 http://www.lfd.uci.edu/~gohlke/pythonlibs/

在实际上,建立一些Python包需要C编译器(例如,的mingw32)和依赖库头。这可以是Windows上的噩梦,所以记住了这个名字克里斯托夫Gohlke。

我在 Windows 上安装软件包时遇到问题。找到了解决方案。它适用于 Windows7+。主要是任何带有 Windows Powershell 的东西都应该能够使其工作。 可以帮助您开始使用它。

  • 首先,您需要将 python 安装添加到 PATH 变量中。 应该有帮助。
  • 您需要下载要安装的 zip 格式的包并将其解压缩。如果它是一些奇怪的 zip 格式,请使用 7Zip 并且应该将其提取。
  • 使用 Windows Powershell 导航到使用 setup.py 提取的目录(如果遇到问题,请使用其链接)
  • 运行命令 python setup.py install

当其他事情都没有任何意义时,这对我很有用。我使用 Python 2.7,但文档表明同样适用于 Python 3.x。

您也可以只需下载并运行ez_setup.py,虽然setuptools的文档不再显示此。工作得很好,我最近在2个星期前。

PS D:\simcut>  C:\Python27\Scripts\pip.exe install networkx
Collecting networkx
c:\python27\lib\site-packages\pip\_vendor\requests\packages\urllib3\util\ssl_.py:318: SNIMissingWarning: An HTTPS reques
t has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may caus
e the server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade to a newer ve
rsion of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#snimissi
ngwarning.
  SNIMissingWarning
c:\python27\lib\site-packages\pip\_vendor\requests\packages\urllib3\util\ssl_.py:122: InsecurePlatformWarning: A true SS
LContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL con
nections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.
readthedocs.io/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
  Downloading networkx-1.11-py2.py3-none-any.whl (1.3MB)
    100% |################################| 1.3MB 664kB/s
Collecting decorator>=3.4.0 (from networkx)
  Downloading decorator-4.0.11-py2.py3-none-any.whl
Installing collected packages: decorator, networkx
Successfully installed decorator-4.0.11 networkx-1.11
c:\python27\lib\site-packages\pip\_vendor\requests\packages\urllib3\util\ssl_.py:122: InsecurePlatformWarning: A true SSLContext object i
s not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade
to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#insecureplat
formwarning.
  InsecurePlatformWarning

或者只是把目录画中画可执行在你的系统路径。

正如Blauhirn提到2.7 PIP预装之后。如果它不为你工作,可能需要被添加到路径。

不过,如果你运行Windows 10,你不再需要打开一个终端安装模块。这同样适用于打开的Python以及

可以直接输入到搜索菜单pip install mechanize,选择命令和它将安装:

“在这里输入的图像描述”

如果出现任何错误但它可能会关闭之前,你可以读取错误,但仍然是一个有用的快捷方式。

点子是Python的安装程序包,首先更新,然后下载你所需要的。

python -m pip install --upgrade pip

然后:

python -m pip install <package_name>
  

升级经由命令提示画中画(Python的目录)

D:\Python 3.7.2>python -m pip install --upgrade pip

立即就可以安装所需的模块

D:\Python 3.7.2>python -m pip install <<yourModuleName>>
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top