在 Cygwin 上安装 Python 3.0
问题
使用 Cygwin 安装 Python 3.0 和 Python 2.x 的正确方法是什么?
注释
我已经有 Cygwin 的工作副本,并且 Python 2.x 安装在 Cygwin 中(/lib/python2.x
,而不是 c:\python2.x
)。
另外,我希望能够通过让 python
指向 Python 2.x 来单独调用 python 3(并且只是有意)以保留现有的依赖项。 我想使用 python30 或其他替代方案。
任何有关该主题的指南的指示将不胜感激。 我似乎在 cygwin 网站或 python.org 上都找不到。
The Question
What is the correct way to install Python 3.0 alongside Python 2.x using Cygwin?
Notes
I already have a working copy of Cygwin, and Python 2.x is installed within Cygwin (/lib/python2.x
, not c:\python2.x
).
Also, I would like to be able to call python 3 separately (and only intentionally) by leaving python
pointing to Python 2.x to preserve existing dependencies. I would like to use python30
or some alternative.
Any pointers to guides on the subject would be much appreciated. I cannot seem to find one either at the cygwin site or python.org.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
截至昨天(2012 年 7 月 25 日星期三),Python 3.2.3 已包含在标准 Cygwin 安装程序中。 只需再次运行 Cygwin 的
setup.exe
(如果需要,请再次从 cygwin.com 下载),然后您应该能够像任何其他软件包一样选择并安装它。这将安装为
python3
,保留任何现有的 2.x 安装:As of yesterday (Wed 25 July 2012), Python 3.2.3 is included in the standard Cygwin installer. Just run Cygwin's
setup.exe
again (download it from cygwin.com again if you need to), and you should be able to select and install it like any other package.This will install as
python3
, leaving any existing 2.x install in place:Python 3.0 源的标准
make install
目标不安装 python 二进制文件。 相反,在最后进行安装打印所以不用担心。
如果您想轻松删除整个安装,请执行类似
configure --prefix=/usr/local/py3
的操作The standard
make install
target of the Python 3.0 sources doesn't install a python binary. Instead, make install prints at the endSo don't worry.
If you easily want to remove the entire installation, do something like
configure --prefix=/usr/local/py3
要以非侵入式方式使用 Python 3,如果您还没有 Python 3,请在用户主目录中创建一个名为“.bash_profile”的文件。
设置一个指向您的 Python 3 安装的别名。 在我的 Windows 计算机上,这看起来像这样:
根据安装位置调整路径,如果在 Windows 上,请小心确保使用 UNIX 换行符,否则您将收到诸如“bash: $'\ r':找不到命令”。
您现在应该能够使用“python3”命令,并且您还没有修改 Cygwin 附带的 Python 版本。
To use Python 3 in a non-intrusive manner, if you don't have one already, create a file called ".bash_profile" in your user home directory.
Set up an alias pointing at your Python 3 install. On my Windows machine this looks like so:
Adjust the path according to where your install is located, and if on Windows, be careful to ensure you're using UNIX line breaks or you will get a message such as "bash: $'\r': command not found".
You should now be able to use the "python3" command, and you haven't modified the version of Python that came with Cygwin.
在 Perl 世界中,我总是安装自己的,带有一个前缀:
我从来不想处理我的操作系统附带的任何 Perl,因为我不想为其安装库,并且可能会弄乱在 Perl 中编写的脚本。操作系统。
我对 Cygwin 做了同样的事情,因为能够安装我自己的模块并且不用担心 Cygwin 更新会破坏它们对我来说要好得多。
如果我学习Python(我愿意),我打算做同样的事情。
这样我就可以独立地将各个应用程序从一个版本升级到另一个版本。
对于真正重要的应用程序(例如主要的 Web 应用程序),我什至可能会进行由专用于该应用程序的用户拥有的独立安装。
Over in the Perl world, I always install my own, with a prefix:
I never want to deal with whatever perl came with my OS, as I don't want to install libraries for it and potentially mess up scripts that were written in the OS.
I do the same thing for Cygwin, as it's much nicer for me to be able to install my own modules and not worry that Cygwin update will trash them.
If and when I learn Python (I'd like to), I intend to do the same thing.
This way I can upgrade individual applications from one version to another independently.
For really serious applications (like a major web app), I might even do a self-contained installation owned by a user dedicated to the app.
不用从命令行调用 python,只需调用 python3,如下所示:
instead of invoking python from the command line just invoke python3 like so: