Tag Archives: nanocut

How to install your own Python modules or specific Python version

First time only

No root access is required at any point!

If this is the first time you read this guide, you will need to install the program pyenv. This is done by typing the following commands:

1. Download pyenv

$ git clone git://github.com/yyuu/pyenv.git ~/.pyenv

2. Make pyenv configuration file (to source when you need to use it)

$ mkdir ~/env
$ echo 'export PYENV_ROOT="$HOME/.pyenv"' > ~/env/pyenv
$ echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/env/pyenv
$ echo 'eval "$(pyenv init -)"' >> ~/env/pyenv

Installing your own Python version

This section will show you how to install your own version of python. First you will have to decide which version of python you want to install. The de facto standard version of python today is 2.7.6 so this guide will show you how to install that version.

1. Get pyenv to install the python version of your liking.

$ pyenv install 3.4.0

2. Make the version you just installed to the standard version for every time you run python.

$ pyenv global 3.4.0

Now you should be all set. If you change your mind about which version of Python to use, just redo this section and choose a different version. You can also have multiple versions installed at the same time and just switch between them usuing ‘pyenv global’ as shown above, if you have a script that requires Python 3.x or any other version.

Installing modules

First, open a new terminal and run “$source ~/env/pyenv”. To be able to install your own python modules, you will first have to follow the sections ‘First time only’ and ‘Installing your own Python version’ above.

To install modules in your python, use pip

$ pip install [module name]

Example:

$ pip install numpy

Installing modules via setup.py

Unpack the package if necessary (example for nanocut)

$ tar -xvzf nanocut-12.12.tar.gz
$ cd nanocut-12.12

Then follow the installation instructions (example for nanocut)

$ python setup.py install

Run this after installing executables

$ pyenv rehash

Using the pyenv setup

In a new terminal source the pyenv setup

$ source ~/env/pyenv

Enjoy your own python version installation!

Useful commands to know

Within the pyenv (i.e. after you have sourced the configuration)

# List the available python environments that could be installed
$ pyenv versions --list

# Change to another version that you have installed
$ pyenv global 2.6.7

# Uninstall previously installed version
$ pyenv uninstall 3.3.3

$ pip freeze
$ pip list --outdated
$ pip install --upgrade SomePackage

 

Links:

http://www.uppmax.uu.se/how-to-install-your-own-python-modules-or-specific-python-version
https://aradi.bitbucket.org/nanocut/installation.htmlhttps://pypi.python.org/pypi/pip