Ashley Liu
Ashley Liu

Reputation: 463

Cannot install Python 3.6.8 in virtualenv on Ubuntu 16.04

I am running an AWS EC2 Ubuntu 16.04 instance. I cannot get Python 3.6.8 working in virtualenv. Here is what I did after starting the Ubuntu instance:

1) sudo apt-get update

2) sudo apt-get upgrade

3) Installed Python 3.6.8 according to instruction here: https://tecadmin.net/install-python-3-6-ubuntu-linuxmint/

4) Verified installation with python3.6 -V (console returned "Python 3.6.8")

5) Installed pip3 with sudo apt-get -y install python3-pip

6) Installed virtualenv with sudo pip3 install virtualenv

7) Upgraded pip3 with sudo -H pip3 install --upgrade pip

8) Created virtualenv with virtualenv -p python3 venv

When I activated my virtual env and checked Python version with python3 -V, the console returned "Python 3.5.2". Even after I deactivated the virtual env and checked Python version again, I still get "Python 3.5.2". I never installed Python 3.5 in this Ubuntu system; everything I did to this system is listed above. I tried a few times with new Ubuntu instances and the virtual env changes my Python version to 3.5 every time. What's going on here? I really need Python 3.6.8.

Upvotes: 1

Views: 4307

Answers (1)

eddyizm
eddyizm

Reputation: 585

Looks like you need to create the virtualenv using the specific python version.

virtualenv -p python3.6 venv

I would verify this by exiting your virtualenv and then checking to see what python3 returns in the base environment

python3 --version

Upvotes: 2

Related Questions