In this example, I install python2 and python3 environments and run them from within the same shell.
#first we get the minicondas
wget https://repo.anaconda.com/miniconda/Miniconda2-latest-Linux-x86_64.sh
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
#then we install them. At the installation stage it is important to have a clean environment with no PYTHONPATHS set
bash Miniconda2-latest-Linux-x86_64.sh -b -p /gpfs/home/sstagg/miniconda2_test
bash Miniconda3-latest-Linux-x86_64.sh -b -p /gpfs/home/sstagg/miniconda3_test
#then we install dependencies
./miniconda2_test/bin/conda install scipy numpy matplotlib
./miniconda3_test/bin/conda install scipy numpy matplotlib
Now we have two different python environments in my home directory
In the following test scripts, I have each script call its own python by having them point to the right python in the #! line at the top of the script.
test2.py
#!/gpfs/home/sstagg/miniconda2_test/bin/python
import numpy
import matplotlib
from matplotlib import pyplot
print "Using python2.7"
print "numpy version", numpy.__version__, numpy.__path__
print "matplotlib version", matplotlib.__version__, matplotlib.__path__
x=numpy.arange(1,100,1)
y=x*x
pyplot.plot(x,y)
pyplot.show()
test3.py
#!/gpfs/home/sstagg/miniconda2_test/bin/python
import numpy
import matplotlib
from matplotlib import pyplot
print ("Using python3.7.3")
print ("numpy version", numpy.__version__, numpy.__path__)
print ("matplotlib version", matplotlib.__version__, matplotlib.__path__)
x=numpy.arange(1,100,1)
y=x*x
pyplot.plot(x,y)
pyplot.show()