User Tools

Site Tools


working_with_python

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
working_with_python [2019/02/20 13:49]
lenocil [Working with Python]
working_with_python [2019/09/12 13:30] (current)
lenocil
Line 67: Line 67:
   * When globally installed packages are on the python path, and they satisfy the installation requirements,​ pip does nothing, and reports that requirement is satisfied.   * When globally installed packages are on the python path, and they satisfy the installation requirements,​ pip does nothing, and reports that requirement is satisfied.
   * pip will not perform a --user install in a virtualenv unless the virtualenv was created specifying ''​--system-site-packages''​. Nonetheless,​ pip will never install a package that conflicts with a package in the virtualenv site-packages.   * pip will not perform a --user install in a virtualenv unless the virtualenv was created specifying ''​--system-site-packages''​. Nonetheless,​ pip will never install a package that conflicts with a package in the virtualenv site-packages.
 +
 +=== Method 1 - subsection Incompatible versions ===
 +
 +Unfortunately,​ python'​s '​user'​ directory is independent of the operating system version, but most of the compute nodes including the LOFAR cluster, run RedHat Enterprise Linux, which is sufficiently different to cause packages installed on the desktop not to work all the time.
 +
 +In cases like this, it might be necessary to create a separate python user directory structure for those machines:
 +
 +Add to your .bashrc something like this:
 +  if [ ! -f /​etc/​fedora-release ]; then
 +    export PYTHONUSERBASE=$HOME/​.local-rhel7
 +  fi
 +For users of the ''​tcsh''​ shell, add this to your .cshrc in stead:
 +  if (! -f /​etc/​fedora-release) then
 +    setenv PYTHONUSERBASE $HOME/​.local-rhel7
 +  endif
 +
 +And make sure to create that directory ~/​.local-rhel7. Now the pip --user commands on RHEL7 machines will install into that newly created directory in stead of the default one used by the desktop systems.
  
 ==== METHOD 2: virtualenv ==== ==== METHOD 2: virtualenv ====
Line 79: Line 96:
  
 Please note that your newly created virtual environment will be a `python2'​ one if you used `virtualenv'​ or a Please note that your newly created virtual environment will be a `python2'​ one if you used `virtualenv'​ or a
- ​`python3'​ one if using `virtualenv-3'​.+ ​`python3'​ one if using `virtualenv-3'. Note that if the command `virtualenv-3'​ is missing you could use ''​virtualenv -p /​usr/​bin/​python3'​'​. ​
  
 The last step before starting to use the newly generated environment is to activate it, that is to prepend its /bin folder to your $PATH environment variable. This is done by issuing The last step before starting to use the newly generated environment is to activate it, that is to prepend its /bin folder to your $PATH environment variable. This is done by issuing
working_with_python.1550670570.txt.gz ยท Last modified: 2019/02/20 13:49 by lenocil