2

I need to use Python 3.4 on a CentOS system where only Python 2.x is available. But I don't have privileges to install new software.

Is there a way to use pyvenv-3.4 without Python 3.4 installed?

E.g. I would download and unpack Python 3.4:

wget https://www.python.org/ftp/python/3.4.3/Python-3.4.3.tgz
tar -xvzf Python-3.4.1.tgz

and then somehow use pyvenv-3.4 from the unpacked source.

I am aware of this thread Use different Python version with virtualenv, but want to be sure about this. Especially about this comment.

Community
  • 1
  • 1
Dušan Maďar
  • 9,269
  • 5
  • 49
  • 64

1 Answers1

2

I don't know if it's possible to do it that way, but you can build any version of python in your home drive that you can then use for development. What you do need is the development tools installed for your distribution i.e. GCC, etc.


Step 1: Download the source code and extract it somewhere.

Step 2: Create a directory in your home directory (in this example ~/opt)

Step 3: Open a terminal and cd into the directory where you expanded the source files.

Step 4: Execute the following: ./configure --prefix=/home/your_username/opt/python

Step 5: Execute make

Step 6: Execute make install

Step 7: Check that it works by executing ~/opt/python/bin/python. You should get the following:

Python 3.4.3 (default, Apr 27 2015, 16:41:03) 
[GCC 4.9.2 20150212 (Red Hat 4.9.2-6)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 

Do what you like with it, just remember you need to point to it.

You can have as many private versions of python as you like without making changes to the main system's versions - just change the --prefix.

Added info:

For pip to get built, you need openssl-devel installed on the system.

To build your environment, run ~/opt/python/bin/python3 -m venv directory_name

Maximillian Laumeister
  • 19,884
  • 8
  • 59
  • 78
  • 2
    I have posted a blog over on Codrspace where I have a detailed a step by step instructions for both Python 2 and 3 [link](http://codrspace.com/ReclusiveGeek/Building-python-from-source-the-why-and-how/) – ReclusiveGeek May 01 '15 at 18:19