First, check to see where our current python installation is located:
> which python # And
> which python3
As well, see if there is a pip installation on the global system (some systems will not have a system wide installation i.e. chyenne)
> which python3
> which pip3
Create the vitural enviornment on the command line:
> python3 -m venv cl_env
Check to make sure the enviornment we created exists. You should see that there is
now a directory called cl_env
in our current dirrectory.
> ls
Source the enviornment so that our shell gains access to it and its installed modules:
> source cl_env/bin/activate # For Bash
> source cl_env/bin/activate.csh # For tcsh or csh
[cl_env] > # Our prompt should now change to refelct that we have the enviornment
[cl_env] > # as these new lines have.
Now check to see where our Python and Pip installations are located:
[cl_env] > which python3 # The output should look something like the following:
.../cl_env/bin/python3
[cl_env] > which pip3 # Likewise the output should look something like:
.../cl_env/bin/pip3
Now lets install numpy for our python3 in our vitural enviornment:
[cl_env] > pip3 install numpy
Loads of pip output here, which should end with: 'Successfully installed numpy-' followed by a version number
[cl_env] > # Check to see what packages we have instalelled (Should be just numpy)
[cl_env] > pip3 freeze
numpy==1.16.1
Now run numpy_test.py
to show that our enviornment has numpy installed:
python numpy_test.py
Return to our orginal enviornment by typeing decativate
[cl_env] > deactivate
> # Promp changes back to normal, and now our python installations should be where they were before.
> which python3