brad
brad

Reputation: 75404

Installing Python 3.0 on Cygwin

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.

Upvotes: 16

Views: 52124

Answers (5)

umbregachoong
umbregachoong

Reputation: 349

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

python3 script1.py

Upvotes: 0

me_and
me_and

Reputation: 15634

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

Upvotes: 16

Steve
Steve

Reputation: 9480

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.

Upvotes: 5

skiphoppy
skiphoppy

Reputation: 102713

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.

Upvotes: 3

Martin v. Löwis
Martin v. Löwis

Reputation: 127447

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

Upvotes: 10

Related Questions