简体   繁体   English

如何在 Windows 上安装 .egg Python 包(尝试使用 easy_install 不起作用)

[英]How can I install a .egg Python package on Windows (attempt using easy_install not working)

I am trying to install a package named QSTK for a course that I am doing.我正在尝试为我正在做的课程安装一个名为 QSTK 的包。 The course points to an installation package for the 32 bit version, but I have 64 Python installed.课程指向32位版本的安装包,但我安装了64位Python。 I have found a .egg file listed on the Python packages index .我在Python 包索引中找到了一个 .egg 文件。

It seems to have an exe for 32 bit, but just the .egg for 64 bit.它似乎有一个 32 位的 exe,但只有 64 位的 .egg。 I downloaded the QSTK-0.2.6-py2.7.egg version and have been trying to install this unsucessfully so far.我下载了 QSTK-0.2.6-py2.7.egg 版本,到目前为止一直在尝试安装它,但没有成功。

Here is what I have tried:这是我尝试过的:

  1. Using easy install (from the C:\\Python27\\Lib\\site-packages directory):使用简易安装(从 C:\\Python27\\Lib\\site-packages 目录):

     Python easy_install -ZC:\\Users\\Prosserc\\Downloads\\QSTK-0.2.6-py2.7.egg

    this has created a QSTK-0.2.6-py2.7.egg directory in my site-packages directory which I can open and find files in. However, I have tried to import QSTK from the python shell and get the usual "No module named..." import error.这在我的站点包目录中创建了一个 QSTK-0.2.6-py2.7.egg 目录,我可以打开并在其中查找文件。但是,我尝试从 python shell 导入 QSTK 并获得通常的“无模块命名...”导入错误。

  2. I looked for a setup.py file as I have used these to install packages before, but could not find one.我找了一个 setup.py 文件,因为我以前用它们来安装软件包,但找不到。

  3. I have also looked at this thread which gives details of installing a .egg file without using easy install, but cannot figure out what changes I would need to make to the script provided as this is to install a specific package that I already have.我还查看了这个线程,它提供了在不使用简单安装的情况下安装 .egg 文件的详细信息,但无法弄清楚我需要对提供的脚本进行哪些更改,因为这是安装我已经拥有的特定包。

If anyone can help by explaining either how I can install this .egg file correctly or by providing a link to the QSTK modules for python 2.7 64 bit in another format this would be greatly appreciated.如果有人可以通过解释我如何正确安装此 .egg 文件或通过提供另一种格式的 python 2.7 64 位 QSTK 模块的链接来提供帮助,我们将不胜感激。

I have managed to install the packages that QSTK is dependant on okay (numpy, scipy, matplotlib, pandas, python-dateutil and scikit-learn).我已经成功安装了 QSTK 依赖的软件包(numpy、scipy、matplotlib、pandas、python-dateutil 和 scikit-learn)。

You should add -m before easy_install您应该在easy_install之前添加-m
for example:例如:

python -m easy_install C:\Users\Prosserc\Downloads\QSTK-0.2.6-py2.7.egg

I have finally found another place to download this from with a package that works: https://pypi.python.org/pypi/QSTK/0.2.6 has a QSTK-0.2.6.tar.gz option to build it from the source code.我终于找到了另一个可以使用一个有效的包下载它的地方: https ://pypi.python.org/pypi/QSTK/0.2.6 有一个 QSTK-0.2.6.tar.gz 选项可以从源代码。

Unzipping this (then again once down to the .tar), I could find the setup.py file and install by going to the directory with the setup file and running:解压缩它(然后再次解压到 .tar),我可以找到 setup.py 文件并通过转到包含安装文件的目录并运行来安装:

python setup.py install

How about if you unpack the .egg (it's just a .zip in disguise), then cd into it and run python setup.py install ?如果你解压.egg (它只是一个伪装的.zip ),然后cd进入它并运行python setup.py install怎么样? Will that run fine and will you then be able to import your module?这会运行良好,然后您可以导入您的模块吗?

I'm saying this because if the .egg file does get put under site-packages as appropriate but you're still not able to import, this might be a problem in the code itself.我这么说是因为如果.egg文件确实被适当地放在site-packages ,但您仍然无法导入,这可能是代码本身的问题。

I tried copying the contents of the .egg folder in the path Lib\\site-packages .我尝试复制路径 Lib\\site-packages 中 .egg 文件夹的内容。 It worked and didn't throw any ModuleNotFoundError .它有效并且没有抛出任何 ModuleNotFoundError 。

我发现pip install qstk在 win 7 下非常适合 64x 2.7 python

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM