2

I have just installed Python 3.4 on Ubuntu 16.04 using the ./configure, make, make install process. I am trying to install Flask, and am having issues using pip in virtualenv created with 3.4. Using pip installs to Python 2.7, pip3 installs to 3.5. Trying any other method produces errors.

How do I invoke pip for Python 3.4.3?

Wafie Ali
  • 287
  • 3
  • 13
paliaso
  • 21

3 Answers3

4

Revised from Creating a virtual environment with python3.4 on Ubuntu 16.04 Xenial Xerus:

  1. Install dependencies.

    sudo apt install build-essential checkinstall  
    sudo apt install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev openssl  
    
  2. Get python3.4 source code.

    mkdir -p $HOME/opt  
    cd $HOME/opt  
    curl -O https://www.python.org/ftp/python/3.4.3/Python-3.4.3.tgz  
    tar xzvf Python-3.4.3.tgz  
    cd Python-3.4.3
    
  3. Configure and install.

    ./configure --enable-shared --prefix=/usr/local LDFLAGS="-Wl,--rpath=/usr/local/lib"  
    sudo make altinstall  
    

    --enable-shared is necessary for some libraries. The --prefix is needed for reasons (more information in this answer). make altinstall keeps your python3.5 installation as the default one.

  4. Create a python3.4 virtualenv.

    Now we can create a new virtual environment and activate it:

    python3.4 -m venv Python3.4VirtualEnv  
    . Python3.4VirtualEnv/bin/activate
    

pip3 is installed by default when the Python 3.4 virtual environment is created. List installed packages:

pip3 list

Returns

Flask (0.11.1)    

Type flask --help to show Flask help. This output shows that Flask has been successfully installed in a Python virtual environment for Python 3.4.

karel
  • 114,770
  • Thank you for your help, this didn't work for me even after a complete 16.04 re-install. I reverted back to 14.04. – paliaso Nov 21 '16 at 13:51
0

To install a specific version, you could do:

pip install 'python==3.4.3' --force-reinstall

or

pip install 'python3==3.4.3' --force-reinstall
muru
  • 197,895
  • 55
  • 485
  • 740
-1

Try the following:

python3.4 -m pip install <packageYouWant>

The same is true if you wanted to specify 3.5 packages:

python3.5 -m pip install <packageYouWant>

Link is here: Python Docs

D75
  • 142