install python 3.3.2

Questions about applications and software
Forum rules
Before you post please read this

install python 3.3.2

Postby salv236 on Sat Aug 03, 2013 11:04 am

Hello,

Im a newbie to Linux im trying to install python in Mint 14.

ive used the command python --version to check what version i currently
have, bash informs me that its 2.7

i did an instally by executing apt-get install python, whats strange is when i try
the command again to verify the veriso it tells me that its still 2.7

I then downloaded the package from python.org untared and went into the directory

I then tried following the steps found on a youtube video where i need to execute sudo ./configure
and sudo make & sudo make install which failed, ehrn i tried the first command i receive the below message

saia@linux /media/ssaia/FREECOM HDD/Python-3.3.2 $ sudo ./configure
sudo: ./configure: command not found

The file exists:

-rw------- 1 ssaia ssaia 439950 May 15 18:33 configure

i tried to chmod +x as it didnt have the executable right to launch however configure permissions remain the same

can someone please assist
salv236
Level 1
Level 1
 
Posts: 7
Joined: Wed Feb 06, 2013 4:57 pm

Linux Mint is funded by ads and donations.
 

Re: install python 3.3.2

Postby xenopeek on Sat Aug 03, 2013 2:46 pm

There are some good ways to break your Linux Mint installation, among them is messing about with trying to install different Python version. Not trying to stop you, but be warned that Python 2.7 must at all times be your system's default Python version! Many system programs are Python 2.7 programs, and won't work if you change your system's default Python version to 3.x. And many pre- and post-install scripts in packages are Python 2.7 programs. Meaning you won't be able to install or remove packages once you've managed to change your system's default Python version. Then it will be "congratulations, you passed the can I break my Linux Mint install test." :)

So with all the above warnings, how do you use Python 3 then? It is of course already installed. Instead of the link "python" use the link "python3". The former links to your system's default Python version (which should be Python 2.7) and the latter links to your system's default Python 3 version. Let's try it out:
Code: Select all
vincent@nadia ~ $ python --version
Python 2.7.3
vincent@nadia ~ $ python3 --version
Python 3.2.3

So Python 3.2.3 is already installed. If you want Python 3.3, just install the package "python3.3". Linux Mint 14 has 3.3.0 as the latest version available. That is the easiest way to get 3.3.x. Or must you really specifically have 3.3.2?

To have a script be run as Python 3, just start it with:
Code: Select all
#!/usr/bin/env python3

Or if you must use a specific version, for example 3.3:
Code: Select all
#!/usr/bin/env python3.3

So yes, also on the command line you can invoke a specific version of Python. For example to get the version of Python 3.2 you could also run the following instead of the earlier "python3 --version":
Code: Select all
vincent@nadia ~ $ python3.2 --version
Python 3.2.3

To see all your Python binaries and how most of these are links:
Code: Select all
ls -l /usr/bin/python*
User avatar
xenopeek
Level 21
Level 21
 
Posts: 14834
Joined: Wed Jul 06, 2011 3:58 am
Location: The Netherlands

Re: install python 3.3.2

Postby xenopeek on Sat Aug 03, 2013 3:08 pm

To follow up the above post, if you must have specifically Python 3.3.2 you'll need to compile it from source. I've adopted the following steps from http://linuxg.net/how-to-install-python ... and-12-04/, changed for Python 3.3.2.

1] You need a few essential packages for being able to compile Python 3.3.2, so install these:
Code: Select all
apt install build-essential libbz2-dev libsqlite3-dev sqlite3

2] Next, download the source, unpack it, and go to the directory containing the source:
Code: Select all
wget http://python.org/ftp/python/3.3.2/Python-3.3.2.tar.bz2
tar jxf Python-3.3.2.tar.bz2
cd Python-3.3.2

3] Next, compile the source and install it:
Code: Select all
./configure --prefix=/opt/python3.3
make && sudo make install

Sit back, this will take a while :wink:

To run Python 3.3.2 use /opt/python3.3/bin/python3.3. For example to get its version:
Code: Select all
vincent@nadia ~ $ /opt/python3.3/bin/python3.3 --version
Python 3.3.2

Or at the top of a script:
Code: Select all
#!/opt/python3.3/bin/python3.3
User avatar
xenopeek
Level 21
Level 21
 
Posts: 14834
Joined: Wed Jul 06, 2011 3:58 am
Location: The Netherlands

Re: install python 3.3.2

Postby salv236 on Sun Aug 04, 2013 7:01 am

hi xenopeek

Thanks for providing me with the process with step 3 i encounter an issue:

linux Python-3.3.2 # ./configure --prefix=/opt/python3.3
-su: ./configure: Permission denied
salv236
Level 1
Level 1
 
Posts: 7
Joined: Wed Feb 06, 2013 4:57 pm

Re: install python 3.3.2

Postby xenopeek on Sun Aug 04, 2013 7:46 am

Are you running the configure command as root? You shouldn't, you should do all the steps as yourself and only the last step is with sudo.
User avatar
xenopeek
Level 21
Level 21
 
Posts: 14834
Joined: Wed Jul 06, 2011 3:58 am
Location: The Netherlands

Re: install python 3.3.2

Postby salv236 on Sun Aug 04, 2013 7:59 am

I managed to install however i, still unable to instruct the system to use python version 3.3 when i code here is a sample file

#! /usr/local/lib/env python3.3

print "Hello World"

When i run this in bask this is what i get:

linux ssaia # ./helloworld.py
-su: ./helloworld.py: /usr/local/lib/env: bad interpreter: No such file or directory
salv236
Level 1
Level 1
 
Posts: 7
Joined: Wed Feb 06, 2013 4:57 pm

Re: install python 3.3.2

Postby xenopeek on Sun Aug 04, 2013 9:23 am

That's not where you installed it... I already wrote how to run scripts with Pythin 3.3.2:
xenopeek wrote:To run Python 3.3.2 use /opt/python3.3/bin/python3.3. For example to get its version:
Code: Select all
vincent@nadia ~ $ /opt/python3.3/bin/python3.3 --version
Python 3.3.2

Or at the top of a script:
Code: Select all
#!/opt/python3.3/bin/python3.3
User avatar
xenopeek
Level 21
Level 21
 
Posts: 14834
Joined: Wed Jul 06, 2011 3:58 am
Location: The Netherlands

Re: install python 3.3.2

Postby WileyECoyote on Sun Feb 02, 2014 12:10 pm

Mostly accurate, but I do not believe that "many pre- and post-install scripts in packages are Python 2.7 programs". I don't recall ever seeing one, not even sure if pre- and post-install scripts are allowed to be anything but sh scripts in debian packages. All else appears to be technically accurate.
WileyECoyote
Level 1
Level 1
 
Posts: 1
Joined: Sun Feb 02, 2014 11:11 am

Linux Mint is funded by ads and donations.
 

Return to Software & Applications

Who is online

Users browsing this forum: Mark Phelps, pcpunk and 24 guests