在 Windows 中安装 Python 模块
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8116986/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Installing a Python module in Windows
提问by MarathonStudios
I'm trying to install a Python module on my Windows computer. I installed the development version of the NetBeans IDE to use as my Python editor, and it seems that they install Jython 2.5 under their own program folder, and force you to use that installation for development.
我正在尝试在我的 Windows 计算机上安装 Python 模块。我安装了 NetBeans IDE 的开发版本作为我的 Python 编辑器,他们似乎在自己的程序文件夹下安装了 Jython 2.5,并强制您使用该安装进行开发。
I've been trying to install the PyWhois module for half an hour now, and I'm getting pretty infuriated with the kludginess of developing Python on Windows with Netbeans.
我已经尝试安装 PyWhois 模块半小时了,我对在 Windows 上使用 Netbeans 开发 Python 的笨拙感到非常恼火。
Does anyone know how to install modules with this setup? Should I destroy my dev environment and use something else that would be less rage-inducing?
有谁知道如何使用此设置安装模块?我应该破坏我的开发环境并使用其他不会引起愤怒的东西吗?
回答by Burhan Khalid
Jython is Python for Java - are you sure this is what you want? I have answered this for "normal" Python for Windows, I assume this is what you are after.
Jython 是用于 Java 的 Python - 您确定这是您想要的吗?我已经为 Windows 的“普通”Python 回答了这个问题,我认为这就是您所追求的。
To use Python under Windows, you need to install the Windows binary installer, which you can download from the Python download page. Make sure you choose the binary installer.
要在 Windows 下使用 Python,您需要安装 Windows 二进制安装程序,您可以从Python 下载页面 下载。确保选择二进制安装程序。
Next, you will need to install setuptools
, which you can get from the python package index (pypi).
接下来,您需要安装setuptools
,您可以从python 包索引 (pypi) 中获取。
Once you have installed both, you have Python available under Windows. You should be able to open a command prompt and type "python" to get the python prompt, it should look like this:
一旦你安装了两者,你就可以在 Windows 下使用 Python。您应该能够打开命令提示符并键入“python”以获取 python 提示符,它应该如下所示:
Python 2.7.1 (r271:86832, Nov 27 2010, 18:30:46) [MSC v.1500 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
Then, to install PyWhois, open a command prompt and type:
然后,要安装 PyWhois,请打开命令提示符并键入:
C:\>easy_install pywhois
You'll see output like this:
你会看到这样的输出:
Searching for pywhois
Reading http://pypi.python.org/simple/pywhois/
Best match: pywhois 0.1
Downloading http://pypi.python.org/packages/source/p/pywhois/pywhois-0.1.tar.gz#
md5=b888dcd990574b7b284d9a9f4b300776
Processing pywhois-0.1.tar.gz
Running pywhois-0.1\setup.py -q bdist_egg --dist-dir c:\docume~1843\locals~1\
temp\easy_install-hugnul\pywhois-0.1\egg-dist-tmp-aarhii
Adding pywhois 0.1 to easy-install.pth file
Installing pywhois-script.py script to C:\Python27\Scripts
Installing pywhois.exe script to C:\Python27\Scripts
Installing pywhois.exe.manifest script to C:\Python27\Scripts
Installed c:\python27\lib\site-packages\pywhois-0.1-py2.7.egg
Processing dependencies for pywhois
Finished processing dependencies for pywhois
To confirm it is installed, you should be able to import it from Python:
要确认它已安装,您应该能够从 Python 导入它:
Python 2.7.1 (r271:86832, Nov 27 2010, 18:30:46) [MSC v.1500 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pywhois
>>>
Netbeans 7.0 has removed Python support (see http://wiki.netbeans.org/Python70Roadmap) for more information.
Netbeans 7.0 已删除 Python 支持(请参阅http://wiki.netbeans.org/Python70Roadmap)以获取更多信息。
This http://wiki.python.org/moin/IntegratedDevelopmentEnvironmentswiki entry lists some other IDEs you can try.
这个http://wiki.python.org/moin/IntegratedDevelopmentEnvironmentswiki 条目列出了一些您可以尝试的其他 IDE。