在Windows中安装Python模块

2 投票
1 回答
20340 浏览
提问于 2025-04-17 06:16

我在我的Windows电脑上尝试安装一个Python模块。我安装了NetBeans IDE的开发版本,打算用它作为我的Python编辑器,但它似乎在自己的程序文件夹下安装了Jython 2.5,并强制我使用这个安装版本来进行开发。

我已经试了半个小时想安装PyWhois模块,真是气得我不行,感觉在Windows上用NetBeans开发Python真是麻烦。

有没有人知道在这种情况下怎么安装模块?我是不是应该放弃现在的开发环境,换一个更简单的工具,别让我这么生气?

1 个回答

5

Jython 是为 Java 设计的 Python,你确定这就是你想要的吗?我之前已经回答过关于“普通” Python 在 Windows 上的使用,我想这可能是你想了解的内容。

要在 Windows 上使用 Python,你需要安装 Windows 的二进制安装程序,你可以从 Python 下载页面 下载。确保你选择的是二进制安装程序。

接下来,你需要安装 setuptools,可以从 Python 包索引 (pypi) 获取。

一旦你安装了这两个东西,你就可以在 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.
>>>

然后,要安装 PyWhois,打开命令提示符并输入:

C:\>easy_install pywhois

你会看到类似这样的输出:

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~1\40843\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

为了确认它是否安装成功,你应该能够在 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 已经取消了对 Python 的支持(更多信息请查看 http://wiki.netbeans.org/Python70Roadmap)。

这个 http://wiki.python.org/moin/IntegratedDevelopmentEnvironments 的维基页面列出了一些你可以尝试的其他集成开发环境(IDE)。

撰写回答