User Tools

Site Tools


python

Differences

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

Link to this comparison view

Both sides previous revision Previous revision
python [2021/12/14 18:25]
root
python [2022/02/18 20:21] (current)
root old revision restored (2020/12/21 19:29)
Line 10: Line 10:
 [[ https://www.python.org/downloads/source/ | Python compiled from source ]] will sometimes install Python modules that won't install in Anaconda.  Recommended [[ environment_modules ]] are python/2.7.15 and 3.6.0. [[ https://www.python.org/downloads/source/ | Python compiled from source ]] will sometimes install Python modules that won't install in Anaconda.  Recommended [[ environment_modules ]] are python/2.7.15 and 3.6.0.
  
-If you type ''python'' at the shell without loading any [[ environment_modules ]], you will get Centos system python2 2.7.5, which is quite old and unsuitable for all but the simplest uses, but needs to be in the default path for some system programs to run.  Default system python3 is 3.7.3 with very few python modules.  These system versions are not modified in order to avoid breaking system utilities.+If you type ''python'' at the shell without loading any [[ environment_modules ]], you will get Centos system Python2, which is quite old and unsuitable for all but the simplest uses, but needs to be in the default path for some system programs to run.  There is no default Python3.
  
 ==Custom Python Setups== ==Custom Python Setups==
Line 16: Line 16:
  
 ==conda== ==conda==
-''conda'' is a utility program for Anaconda Python, see [[ https://docs.conda.io/projects/conda/en/latest/user-guide/getting-started.html| getting-started]]. It is most commonly used as ''conda list'' to show the Python modules in the current environment. ''conda'' was originally designed for Python but can also manage installations of other programs such as ''R''.+''conda'' is a utility program for Anaconda Python, see [[ https://docs.conda.io/projects/conda/en/latest/user-guide/getting-started.html| getting-started]]. It is most commonly used as ''conda list'' to show the Python modules in the current environment.
  
 Some examples of conda commmands are shown below. This shows environments or subversions that have different Python module configurations. If unspecified you will be using the starred "base" environment.  ''conda info'' also finds a base environment for Python2 (not usable here in Python3). There are two custom environments that have been defined by the system (''tf_gpu'' and ''theano-env''), and the user running this doesn't have any environments yet.  Some examples of conda commmands are shown below. This shows environments or subversions that have different Python module configurations. If unspecified you will be using the starred "base" environment.  ''conda info'' also finds a base environment for Python2 (not usable here in Python3). There are two custom environments that have been defined by the system (''tf_gpu'' and ''theano-env''), and the user running this doesn't have any environments yet. 
 +
 <code> <code>
 $ module load python/3.7.3-anaconda $ module load python/3.7.3-anaconda
Line 42: Line 43:
  
 The first time you run ''conda activate'' you should get a message like: The first time you run ''conda activate'' you should get a message like:
 +
 <code> <code>
 CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'. CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.
Line 57: Line 59:
 IMPORTANT: You may need to close and restart your shell after running 'conda init'. IMPORTANT: You may need to close and restart your shell after running 'conda init'.
 </code> </code>
 +
 If you then do ''conda activate bash'' (once) you will see that conda has added some bash code to your ''~/.bashrc'' initialization script.  This is acceptable if all the python you ever run is only Anaconda Python2 or only Anaconda Python3, and in that case you can just leave the modification alone. If you ever use other versions of Python, it is likely to cause problems. In that case, you can edit ''~/.bashrc'' and save the new code section at the end (delimited by comments conda_initialize) as a separate script file which we have saved as  ''/share/apps/bin/conda-3.7.3.sh'': If you then do ''conda activate bash'' (once) you will see that conda has added some bash code to your ''~/.bashrc'' initialization script.  This is acceptable if all the python you ever run is only Anaconda Python2 or only Anaconda Python3, and in that case you can just leave the modification alone. If you ever use other versions of Python, it is likely to cause problems. In that case, you can edit ''~/.bashrc'' and save the new code section at the end (delimited by comments conda_initialize) as a separate script file which we have saved as  ''/share/apps/bin/conda-3.7.3.sh'':
 +
 <code> <code>
 $ cat /share/apps/bin/conda-3.7.3.sh $ cat /share/apps/bin/conda-3.7.3.sh
Line 150: Line 154:
 </code> </code>
 To add a module not in the pip list, To add a module not in the pip list,
 +
 <code> <code>
 pip install peppercorn --user pip install peppercorn --user
 </code> </code>
 +
 To add a module with a different version than the pip list: To add a module with a different version than the pip list:
 +
 <code> <code>
 pip install lxml --user --ignore-installed pip install lxml --user --ignore-installed
 </code> </code>
 +
 To show your local modules, which will be used preferentially to the system modules: To show your local modules, which will be used preferentially to the system modules:
 +
 <code> <code>
 $ pip list --user $ pip list --user
python.txt ยท Last modified: 2022/02/18 20:21 by root