Operations > Computing > FAQ

Custom Python Module or Python Installs

Local python module installs are possible using virtualenv on the Linux Lab systems. In a terminal, run the following shell commands:

$ cd
$ mkdir python-stuff
$ cd python-stuff
$ virtualenv .
...
$ ./bin/pip install pandas
...
$ ./bin/pip install PyOpenGL
...

the last of which may take some time to compile. See the pip docs for more information on searching for and installing packages.

This custom install can then be used as follows:

$ echo 'print "snakes are dangerous"' > foo
$ cat foo
print "snakes are dangerous"
$ ./bin/python foo
snakes are dangerous

Or by editing the "shebang" line to reference the appropriate virtualenv path in the script:

$ pwd
/homes/urlogin/python-stuff

Manually edit the file foo with your favorite editor to include the /homes/urlogin/python-stuff/bin/python line. The file should look something like the following:

$ cat foo
#!/homes/urlogin/python-stuff/bin/python
print "snakes are dangerous"
$ chmod +x foo
$ ./foo
snakes are dangerous

The PATH environment variable could be updated to use this directory and the env(1) command used to select an appropriate python based on the PATH but that will not be covered here.

Install a Custom Version of Python

If you need a specific version of python build and install it under your home directory:

$ wget https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tgz
$ wget https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tgz.asc
$ gpg --keyserver hkp://keys.gnupg.net --recv-keys AA65421D
$ gpg --verify Python-3.6.5.tgz.asc
gpg: Signature made Wed 28 Mar 2018 03:28:12 AM PDT using RSA key ID AA65421D
gpg: Good signature from "Ned Deily (Python release signing key) "
...
$ tar xzf Python-3.6.5.tgz
$ cd Python-3.6.5
$ unset CFLAGS
$ ./configure --prefix=$HOME/python-3.6.5 && make && make install

Scripts can now use the /homes/urlogin/python-3.6.5/bin/python3 path to reference that custom install.

Operations
 
EE logo