0

当我运行一些测试脚本时,我在我的 Windows 机器上看到了这个错误。我已经从网站下载了 ZSI-2.0-rc3。但我不知道把这些文件放在哪里以及如何放置这些文件。有谁知道这件事。我的环境是Windows 7。非常感谢!

4

2 回答 2

3

You almost always need to install a package before you can use it. (There are a few exceptions, where you can just copy the package's code into the same directory as your own source, but in general, you need to install.)

Installing Python Modules in the official documentation, and the Python Packaging User Guide, together provide a complete guide to everything, but here are the basics.


First, some packages come with Windows installers—either official ones available on the project's web page, or in Christoph Gohlke's list. When these exist, it's often easier to just download and run the installer. Just make sure to get the version that goes with your Python—packages for Python 3.4 won't work with 2.7; 64-bit packages won't work with 32-bit Python; etc.


Next, you almost certainly want to install pip, then use it to install everything else.

In fact, most packages have an entry on PyPI, which means you don't even have to download them: just type this on a command line:

pip install ZSI

And it will usually find the ZSI entry on PyPI, download the appropriate version, and install it for you.


But a few packages aren't on PyPI, or don't have installable entries, or sometimes you need a newer version than the official release

In that case, you do have to download them, and then cd into their directory, and then do this:

pip install .

A few packages don't work with pip, for various reasons. (A handful do work with easy_install, but that's pretty rare nowadays, except maybe for Mac users using Apple's pre-installed Python, so let's ignore that.) In that case, you have to do the installation manually. That should always use a script named setup.py, so you can just do this:

C:\Path\to\download> python setup.py install

If not, there should be installation instructions either inside the package (e.g., a file named INSTALL) or on the web page.


Sometimes you'll get an error about not being able to find a C compiler. (If Gohlke or the upstream maintainer has an installer package that's already been compiled, or if PyPI has a wheel file, this isn't an issue.) Some packages have C extension modules, and you need a C compiler to install those, unless you can find a Windows binary. This is too much to explain here, but the PyPA guide has the basics, and there are multiple questions on StackOverflow that cover details like how to configure the setup if you get stuck.

于 2014-09-16T23:11:10.913 回答
-1

它需要出现在您的PYTHONPATH. 检查您的环境变量以确切知道它在哪里。

My Computer -> Properties -> Advanced system settings -> Environment Variables...

你正在寻找PYTHONPATH. 把ZSI文件夹放在那里的任何地方。

如果该变量不存在,您需要将其放入path/to/your/python/installation/Lib

例如C:\python33\Lib

于 2014-09-16T22:46:18.603 回答