Monday, March 25, 2013

Python, installing the right version

I do all my programming in Python. I make heavy use of scipy, numpy, and matplotlib. I also like to do 3D plots in Mayavi. So, these are the packages that I need to make sure are up to date with the versions I want. How do I check this? If they are wrong, what's the best way to update the version? I'm going to find out!

Click on Dash Home
Type terminal
Hit Enter
Run python --version

(while the terminal is open, right click on the icon on the tray and choose to lock it there-- terminal is the starting point for most of my work.)

It turns out, I have
Python 2.7.3


There is a newer production version: Python 3.3.0 (Sept. 29, 2012) From what I read, it looks like it is not a good idea to erase 2.7.3. Rather, one may install 3.3.0 alongside 2.7.3.


I followed the instructions in this answer:
http://askubuntu.com/a/244550 (except with sudo in front of each line, and answered Y to each question)
The tar command takes quite a while (~2 minutes)

except instead of py, I called it py3

I got this error along the way:

running build
running build_ext
sh: 1: cannot create build/temp.linux-x86_64-3.3/multiarch: Permission denied
error: build/temp.linux-x86_64-3.3/multiarch: No such file or directory
make: *** [sharedmods] Error 1


I'm not sure what to make of that... is it a real problem?

Hm, per another website, I tried installing python3 like this:
sudo apt-get install python3

now:
python --version
Python 2.7.3

python3 --version
Python 3.2.3

Hrm. That's the version from April, not the most recent version. Maybe if I update and upgrade.

When I've tried a bunch of stuff like I did here, I'm never sure if it is the most recent line I ran that finally made the change, or all of the steps combined.

I'm surprised that 3.2.3 installed instead of 3.3.0 given that 3.3.0 is the "production version."

Hrm. Well, now I would expect to be able to run things with python and with python3, so that's good. But, I don't like feeling mystified by my inability to install 3.3.0. I also can't figure out how to make all the fonts in this entry identical. How annoying.

--> update, the font problem was with firefox, go to Edit -> Preferences -> Content -> Advanced -> Allow pages to choose their own fonts ... err... not quite fixed

2 comments:

  1. to solve the permission problem you encountered, do the following:
    1. make sure all code is under a local file system. Do not use NFS or autofs.
    2. run as root or use 'sudo'
    That solved my problem.

    ReplyDelete
  2. Thanks! I really need to remember sudo when I run into problems. It seems that some instructions online assume you are already running as root.

    ReplyDelete