Today I learnt how to install Python libraries in a virtual environment (in my case, on the Sanger compute farm), using virtualenv.
Here is how I created a virtual environment called 'raschka' and installed the numpy, scipy, scikit-learn, matplotlib and pandas libraries (specifying particular versions of these) inside a virtual environment. First I created a virtual environment called 'raschka':
% virtualenv -p /usr/bin/python3 raschka
Then I activated it:
% source raschka/bin/activate
Then I installed Python libraries within it:
% pip install numpy==1.21.2
% pip install scipy==1.7.2
% pip install scikit-learn==1.1
% pip install matplotlib==3.4.3
% pip install pandas==1.3.2
To start up Python and load in these libraries I can type:
% python3
>>> import numpy
>>> import scipy
>>> import sklearn
>>> import matplotlib
>>> import pandas
Note that you I can exit the virtual environment by typing:
% deactivate
and then later I can enter it again by typing:
% source raschka/bin/activate
Cool!
No comments:
Post a Comment