在 Cygwin 上安装 Python 3.0

发布于 2024-07-12 23:50:37 字数 369 浏览 6 评论 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

饮惑 2024-07-19 23:50:37

截至昨天(2012 年 7 月 25 日星期三),Python 3.2.3 已包含在标准 Cygwin 安装程序中。 只需再次运行 Cygwin 的 setup.exe(如果需要,请再次从 cygwin.com 下载),然后您应该能够像任何其他软件包一样选择并安装它。

这将安装为 python3,保留任何现有的 2.x 安装:

$ python -V
Python 2.6.8
$ python3 -V
Python 3.2.3
$ ls -l $(which python) $(which python3)
lrwxrwxrwx 1 me Domain Users 13 Jun 21 15:12 /usr/bin/python -> python2.6.exe
lrwxrwxrwx 1 me root         14 Jul 26 10:56 /usr/bin/python3 -> python3.2m.exe

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 -V
Python 2.6.8
$ python3 -V
Python 3.2.3
$ ls -l $(which python) $(which python3)
lrwxrwxrwx 1 me Domain Users 13 Jun 21 15:12 /usr/bin/python -> python2.6.exe
lrwxrwxrwx 1 me root         14 Jul 26 10:56 /usr/bin/python3 -> python3.2m.exe
把梦留给海 2024-07-19 23:50:37

Python 3.0 源的标准 make install 目标不安装 python 二进制文件。 相反,在最后进行安装打印

* Note: not installed as 'python'.
* Use 'make fullinstall' to install as 'python'.
* However, 'make fullinstall' is discouraged,
* as it will clobber your Python 2.x installation.

所以不用担心。

如果您想轻松删除整个安装,请执行类似 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 end

* Note: not installed as 'python'.
* Use 'make fullinstall' to install as 'python'.
* However, 'make fullinstall' is discouraged,
* as it will clobber your Python 2.x installation.

So don't worry.

If you easily want to remove the entire installation, do something like configure --prefix=/usr/local/py3

感情旳空白 2024-07-19 23:50:37

要以非侵入式方式使用 Python 3,如果您还没有 Python 3,请在用户主目录中创建一个名为“.bash_profile”的文件。

设置一个指向您的 Python 3 安装的别名。 在我的 Windows 计算机上,这看起来像这样:

alias python3=/cygdrive/d/apps/Python31/python
export python3

根据安装位置调整路径,如果在 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:

alias python3=/cygdrive/d/apps/Python31/python
export python3

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.

风筝在阴天搁浅。 2024-07-19 23:50:37

在 Perl 世界中,我总是安装自己的,带有一个前缀:

./configure --prefix=/usr/local/perl/5.10.0

我从来不想处理我的操作系统附带的任何 Perl,因为我不想为其安装库,并且可能会弄乱在 Perl 中编写的脚本。操作系统。

我对 Cygwin 做了同样的事情,因为能够安装我自己的模块并且不用担心 Cygwin 更新会破坏它们对我来说要好得多。

如果我学习Python(我愿意),我打算做同样的事情。

这样我就可以独立地将各个应用程序从一个版本升级到另一个版本。

对于真正重要的应用程序(例如主要的 Web 应用程序),我什至可能会进行由专用于该应用程序的用户拥有的独立安装。

Over in the Perl world, I always install my own, with a prefix:

./configure --prefix=/usr/local/perl/5.10.0

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.

画离情绘悲伤 2024-07-19 23:50:37

不用从命令行调用 python,只需调用 python3,如下所示:

python3 script1.py

instead of invoking python from the command line just invoke python3 like so:

python3 script1.py
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文