Difference between revisions of "Python/pip"
m |
|||
Line 5: | Line 5: | ||
== Usage == | == Usage == | ||
− | Python and its most commonly used libraries (NumPy, SciPy, Matplotlib) are usually available as a module. Please notice that an older version may be set as default. If the version you need is not available, you can install it in your directory by using 'pip' or 'easy_install'. | + | Python and its most commonly used libraries (NumPy, SciPy, Matplotlib) are usually available as a module. Please notice that an older version may be set as default and there might be modules for different versions. If the version you need is not available, you can install it in your directory by using 'pip' or 'easy_install'. |
+ | You can check the used Version with: | ||
+ | <syntaxhighlight lang="bash"> | ||
+ | $ python --version | ||
+ | </syntaxhighlight> | ||
− | + | and the corresponding install directory with | |
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
− | $ | + | $ which python |
− | |||
− | |||
− | |||
</syntaxhighlight> | </syntaxhighlight> | ||
− | |||
+ | and then use | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
− | $ | + | $ python my_program.py |
</syntaxhighlight> | </syntaxhighlight> | ||
+ | to execute your code. | ||
− | |||
== Pip == | == Pip == | ||
Pip is a package management system for Python and is automatically included since Python 2.7.9/3.4. It enables managing lists of packages and their versions. If you aim to install packages for Python3, use <code>pip3</code> instead of <code>pip</code> with the commands below. | Pip is a package management system for Python and is automatically included since Python 2.7.9/3.4. It enables managing lists of packages and their versions. If you aim to install packages for Python3, use <code>pip3</code> instead of <code>pip</code> with the commands below. | ||
+ | |||
+ | Example: | ||
+ | <syntaxhighlight lang="bash"> | ||
+ | $ pip install --user theano | ||
+ | </syntaxhighlight> | ||
Getting the list of the installed packages: | Getting the list of the installed packages: |
Revision as of 15:41, 25 February 2019
General
Python is an Open Source, interpreted high-level programming language which is popular for prototyping high end simulations and data science applications. In addition to a large standard library there are many thirdparty libraries available (e.g. Numpy, Scipy). However, it is a single threaded environment and therefore may not be most suitable for very large simulations.
Usage
Python and its most commonly used libraries (NumPy, SciPy, Matplotlib) are usually available as a module. Please notice that an older version may be set as default and there might be modules for different versions. If the version you need is not available, you can install it in your directory by using 'pip' or 'easy_install'.
You can check the used Version with:
$ python --version
and the corresponding install directory with
$ which python
and then use
$ python my_program.py
to execute your code.
Pip
Pip is a package management system for Python and is automatically included since Python 2.7.9/3.4. It enables managing lists of packages and their versions. If you aim to install packages for Python3, use pip3
instead of pip
with the commands below.
Example:
$ pip install --user theano
Getting the list of the installed packages:
$ pip list
Pip can also list the packages with outdated versions or available prereleases:
$ pip list --outdated
$ pip list --pre
Packages can easily be installed through the pip install command (specify --user
to install locally):
$ pip install [--user] my-package
The same goes for uninstalling packages:
$ pip uninstall my-package
Upgrade the packages specified to the latest version:
$ pip install --upgrade package1 [package2 ...]
The present packages can be stored as a 'requirements' file. If properly formatted, this file can then be used to recreate the given environment on another system with exactly the same packages and versions:
$ pip install -r requirements.txt
Note: pip3 [...]
can be used interchangeably with:
$ python3 -m pip [...]
Tutorials
As there are plenty of python tutorials available online we decided not to create our very own but instead simply list a few we consider to be most helpful.
https://docs.python.org/3/tutorial/
https://www.w3schools.com/python/
https://www.tutorialspoint.com/python/