entornos python

De Wikicima
Saltar a: navegación, buscar

The generation of environments facilitate the specific requiremnts of each user for each purpose.

Following instructions from python environments

  1. Creation of the place where the environment will reside
$ mkdir -p ${HOME}/bin/py27env
$ cd ${HOME}/bin/py27env
  1. Install virtualenv
$ pip install virtualenv
  1. Test installation
$ virtualenv --version
  1. Create a virtual environment (e.g `py27env' to be used with python 2.7):
$ virtualenv -p /usr/bin/python2.7 ./
  1. Activate the environment
$ source ${HOME}/bin/py27env/bin/activate
(py27env) $
  1. Installing packages
(py27env) $ pip install numpy
Collecting numpy
  Using cached numpy-1.13.3-cp27-cp27mu-manylinux1_x86_64.whl
Installing collected packages: numpy
Successfully installed numpy-1.13.3
  1. To know which packages are installed
(py27env) $ pip freeze
numpy==1.13.3
  1. With the activation of the environment, one directly uses the python from it
(py27env) $ which python
/home/lluis.fita/bin/py27env/bin/python
  1. Deactivating environment
(py27env) $ deactivate
$ 

Matplotlib

There are certain installation problems referred to the `mpl_toolkit'

  1. On a given instaltion:
(py27env) $ pip freeze
backports.functools-lru-cache==1.4
cycler==0.10.0
ecmwf-api-client==1.5.0
matplotlib==2.1.0
netCDF4==1.3.1
numpy==1.13.3
pyparsing==2.2.0
python-dateutil==2.6.1
pytz==2017.3
scipy==1.0.0
six==1.11.0
subprocess32==3.2.7
  • There is not `basemap'
from mpl_toolkits.basemap import Basemap
ImportError: No module named basemap
  • but it is not found in the pip
(py27env) $ pip install basemap
Collecting basemap
  Could not find a version that satisfies the requirement basemap (from versions: )
No matching distribution found for basemap
  • Installing directly from matpotlib
(py27env) $ pip install https://github.com/matplotlib/basemap/archive/v1.1.0.tar.gz
  • Or we will need to manually install `matplotlib' and `basemap' (following Matplolib installation. Unpacking the different packages...
(py27env) $ mkdir $HOME/Downloads
(py27env) $ cd Downloads/
Herramientas personales