Action
This document will give you a quick overview of installing custom packages into python. There are two primary ways to do so, one is with pip install --user
and the other is virtualenv
; both have advantages and disadvantages.
Instructions
Using virtualenv
Here are the examples using virtualenv
, the benefit here is that in a shared space many users could collaborate on one custom instances of packages for their group if the venv is created inside a lab share.
Python 2.7
Here we see that numpy is not installed.
Code Block |
---|
ew2193@headnode7.rit.albany.edu:~/python_project 2.08 1.66 1.00 3/201 5951
1031 > /network/rit/misc/software/python2/bin/python2.7
Python 2.7.12 (default, Aug 10 2016, 15:38:28)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-16)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named numpy
>>> |
Here we will use virtualenv
to setup a virtual python installation and activate it.
Code Block |
---|
ew2193@headnode7.rit.albany.edu:~/python_project 2.08 1.66 1.00 3/201 5951
1032 > virtualenv venv
New python executable in /network/rit/home/ew2193/python_project/venv/bin/python
Installing setuptools, pip, wheel...done.
ew2193@headnode7.rit.albany.edu:~/python_project 2.08 1.66 1.00 3/201 5951
1033 > source venv/bin/activate
(venv) |
Once activated we can use the standard tools like pip
to install additional standard libraries.
Code Block |
---|
ew2193@headnode7.rit.albany.edu:~/python_project 2.08 1.66 1.00 3/201 5951
1034 > pip install numpy
Collecting numpy
Downloading numpy-1.11.1-cp27-cp27m-manylinux1_x86_64.whl (15.3MB)
100% |████████████████████████████████| 15.3MB 59kB/s
Installing collected packages: numpy
Successfully installed numpy-1.11.1
(venv)
ew2193@headnode7.rit.albany.edu:~/python_project 2.08 1.66 1.00 3/201 5951
1035 > python
Python 2.7.12 (default, Aug 10 2016, 15:38:28)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-16)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> help(numpy)
Help on package numpy:
NAME
numpy
FILE
/network/rit/home/ew2193/python_project/venv/lib/python2.7/site-packages/numpy/__init__.py
DESCRIPTION
NumPy
===== |
If we deactivate
we are back to the system level python and stock packages.
Code Block |
---|
ew2193@headnode7.rit.albany.edu:~/python_project 2.08 1.66 1.00 3/201 5951
1036 > deactivate
ew2193@headnode7.rit.albany.edu:~/python_project 2.08 1.66 1.00 3/201 5951
1037 > python
Python 2.7.5 (default, Nov 21 2015, 00:39:04)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named numpy
>>> |
Python 3
Here is the same set of commands using python3 rather than python2. You will notice only slight changes from the python2 version.
Code Block |
---|
ew2193@headnode7.rit.albany.edu:~/python_project 2.08 1.66 1.00 3/201 5951
1039 > /network/rit/misc/software/python3/bin/virtualenv venv
Using base prefix '/network/rit/misc/software/python3'
New python executable in /network/rit/home/ew2193/python_project/venv/bin/python3.5
Also creating executable in /network/rit/home/ew2193/python_project/venv/bin/python
Installing setuptools, pip, wheel...done.
ew2193@headnode7.rit.albany.edu:~/python_project 2.08 1.66 1.00 3/201 5951
1040 > /network/rit/misc/software/python3/bin/python3
Python 3.5.2 (default, Aug 10 2016, 14:35:13)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-16)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'numpy'
>>>
ew2193@headnode7.rit.albany.edu:~/python_project 2.08 1.66 1.00 3/201 5951
1041 > source venv/bin/activate
(venv)
ew2193@headnode7.rit.albany.edu:~/python_project 2.08 1.66 1.00 3/201 5951
1042 > pip3 install numpy
Collecting numpy
Using cached numpy-1.11.1-cp35-cp35m-manylinux1_x86_64.whl
Installing collected packages: numpy
Successfully installed numpy-1.11.1
(venv)
ew2193@headnode7.rit.albany.edu:~/python_project 2.08 1.66 1.00 3/201 5951
1043 > python3
Python 3.5.2 (default, Aug 10 2016, 14:35:13)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-16)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>>
(venv)
ew2193@headnode7.rit.albany.edu:~/python_project 2.08 1.66 1.00 3/201 5951
1045 > deactivate
ew2193@headnode7.rit.albany.edu:~/python_project 2.08 1.66 1.00 3/201 5951
1046 > python3
Python 3.5.2 (default, Aug 10 2016, 14:35:13)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-16)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'numpy'
>>> |
Include Page | ||||
---|---|---|---|---|
|