Re: [Tutor] specifying my default python installation

2012-08-17 Thread Prasad, Ramit
 I am new to both freebsd and python.
 I have python 2.6 and 3.2 both installed on freebsd.
 python runs python 2.6 and I need to use python3.2 to run python 3.2
 Do I need to do something to make python 3.2 the default?

I am not really familiar with BSD but *nix has the application 
update-alternatives. That will do what you want. Otherwise,
you could change the name/location in the bin directory.
It is likely that python is a symlink to python2.6 and all
you need to do is change the symlink to point to python3.2.
If no symlink is used you can rename the binaries instead.

Apologies in advanced if this is way off base.



Ramit

This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.  
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] specifying my default python installation

2012-08-17 Thread Debby Mendez
OK thanks.  It sounds like maybe this is all normal then, not an indication
that something went wrong with my 3.2 install.

-Original Message-
From: tutor-bounces+debby=glance@python.org
[mailto:tutor-bounces+debby=glance@python.org] On Behalf Of Prasad,
Ramit
Sent: Friday, August 17, 2012 11:06 AM
To: tutor@python.org
Subject: Re: [Tutor] specifying my default python installation

 I am new to both freebsd and python.
 I have python 2.6 and 3.2 both installed on freebsd.
 python runs python 2.6 and I need to use python3.2 to run python 
 3.2 Do I need to do something to make python 3.2 the default?

I am not really familiar with BSD but *nix has the application
update-alternatives. That will do what you want. Otherwise, you could change
the name/location in the bin directory.
It is likely that python is a symlink to python2.6 and all you need to do is
change the symlink to point to python3.2.
If no symlink is used you can rename the binaries instead.

Apologies in advanced if this is way off base.



Ramit

This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of securities,
accuracy and completeness of information, viruses, confidentiality, legal
privilege, and legal entity disclaimers, available at
http://www.jpmorgan.com/pages/disclosures/email.  
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] specifying my default python installation

2012-08-17 Thread eryksun
On Fri, Aug 17, 2012 at 11:05 AM, Prasad, Ramit
ramit.pra...@jpmorgan.com wrote:

 I am not really familiar with BSD but *nix has the application
 update-alternatives. That will do what you want. Otherwise,
 you could change the name/location in the bin directory.
 It is likely that python is a symlink to python2.6 and all
 you need to do is change the symlink to point to python3.2.
 If no symlink is used you can rename the binaries instead.

Modifying the default to Python 3 sounds like a bad idea. Platforms
are still in transition to 3.x. Some scripts might assume
/usr/bin/python links to python2.x.

On Debian there's a python3 symlink. You can add your own if FreeBSD
doesn't have it. First, if ~/bin doesn't exist, run mkdir ~/bin;
restart your session, and run echo $PATH to verify it's on the
search path.  Then make the link with ln -s /usr/bin/python3.2
~/bin/python3. You'll have to update this when 3.3 is released.

If ~/bin isn't on the PATH, edit ~/.profile and add the following:

if [ -d $HOME/bin ] ; then
PATH=$HOME/bin:$PATH
fi

Also, while it's probably a bit much at first, I recommend using
virtualenv to configure environments with different versions of
Python/packages:

http://www.virtualenv.org
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] specifying my default python installation

2012-08-17 Thread Alan Gauld

On 17/08/12 15:27, debbym wrote:

I am new to both freebsd and python.
I have python 2.6 and 3.2 both installed on freebsd.
python runs python 2.6 and I need to use python3.2 to run python 3.2
Do I need to do something to make python 3.2 the default?


The generic way to do that on *nix is to create/modify the symbolic 
links in the directory holding the binaries.


You should be able to get that with the which command:

which python
which python2
which python3

On my system the latest install package seems to create the 
python2/python3 links itself. I'm not sure what sets up the python link 
- the mysteries of Synaptic package management.


Once you have the directory you can view the links with ls -l
In my case its in /usr/bin so:

$ ls -l /usr/bin/pyth*
lrwxrwxrwx 1 root root   9 2011-08-13 16:04 /usr/bin/python - python2.6
lrwxrwxrwx 1 root root   9 2011-08-13 16:04 /usr/bin/python2 - 
python2.6

-rwxr-xr-x 1 root root 2613296 2010-04-16 15:42 /usr/bin/python2.6
lrwxrwxrwx 1 root root   9 2011-08-13 20:47 /usr/bin/python3 - 
python3.1

-rwxr-xr-x 1 root root 2849576 2011-12-09 21:26 /usr/bin/python3.1


You can then create/modify the links as required using the ln -s command.

HTH
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] specifying my default python installation

2012-08-17 Thread Modulok
On 8/17/12, debbym de...@glance.net wrote:
 I am new to both freebsd and python.
 I have python 2.6 and 3.2 both installed on freebsd.
 python runs python 2.6 and I need to use python3.2 to run python 3.2
 Do I need to do something to make python 3.2 the default?

FreeBSD doesn't have an 'alternatives' system like debian flavors. However,
there's nothing wrong with your install. I run FreeBSD on several boxes. On
this box I have python 2.6, 2.7, and 3.2 installed. My default 'python'
executable is a symlink that points to /usr/local/bin/python, which itself is
version 2.6. (The box I'm on is FreeBSD 8.1)

If I want a program to run in python3.2, I put something like this (or
similar) as the shebang line at the top of the file:

#!/usr/bin/evn python3.2

Or to get the interpretter just type 'python3.2'. Don't worry about the shebang
lines being cross platform either; Once you package up your scripts into python
packages, using distutils or similar, all shebang lines will be stripped. Upon
re-installation on the target platform they'll be replaced appropriately. (In
fact, some platforms even put 'env' in /bin instead of FreeBSD's /usr/bin.)

I would also recommend against changing the default 'python' symlink, as some
tools may depend on it being at a specific version. One I can think of off the
top of my head is the third party `xps` tool for searching ports. This is most
notable when talking about python2.x vs. the 3.x branch, as python 3 broke
backward compatibility with things like print statements becoming print
functions.

If you find it irritating to have to type 'python3.2' instead of just 'python',
you could create an alias for your shell, so that 'python' is aliased to
'python3.2'. I use tcsh, so I in my case my $HOME/.cshrc file might look
something like this:

alias python /usr/local/bin/python3.2

Then I would type 'source .cshrc' or logout and back in for changes to take
affect. As an alternative, you could create a symlink from your own bin
directory instead. For example:

cd
mkdir bin
ln -s /usr/local/bin/python3.2 ./bin/python

This should work once you type 'rehash' (in tcsh) or logout and log back in.
Most default installs will list the 'bin' directory, found in a given user's
home directory, on the default $PATH. You can verify this by typing 'echo
$PATH' and making sure '/home/you/bin' is listed. This isn't as good of an
option as simply using the alternate shebangs, as it affectively replaces your
version of python with the version you choose, but it will work.

Finally, if you want to get carried away, you can install a virtual python as
mentioned.

For even more options, you might subscribe to questi...@freebsd.org ;)
-Modulok-
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor