Home > front end >  How to run Python3 virtual environment on CENTOS 7
How to run Python3 virtual environment on CENTOS 7

Time:09-17

I have a machine with Centos 7 installed. By default Centos 7 comes with python 2.7 installed. I have added python 3 but I didn't not change the PATH as I don't want to mess with the default python version used by the operating system.

Now I want to create a project using python 3 and the latest version of django so I have created a virtual environment using the command:

python3 -m venv python3-RIGS-venv

if I try to activate it using:

source python3-RIGS-venv/bin/activate

I get the following error:

Badly placed ()'s.

I assume because the default python is 2.7 and not 3 that I have used to create the venv. I have also tried:

python3 python3-RIGS-venv/bin/activate

with the following result:

File "python3-RIGS-venv/bin/activate", line 4
deactivate () {
          ^
SyntaxError: invalid syntax

and finally:

cd python3-RIGS-venv/bin/
. activate

that gives the following error:

./activate: Permission denied.

So the question is how do I activate a venv created with python3 but on a machine running python 2 as default?

CodePudding user response:

In the venv/bin/ catalog are scripts for activating a virtual environment for different shells. For csh use activate.csh.

  • Related