Python Runtime Environments: Unterschied zwischen den Versionen
Matt (Diskussion | Beiträge) |
Matt (Diskussion | Beiträge) Keine Bearbeitungszusammenfassung |
||
(3 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt) | |||
Zeile 1: | Zeile 1: | ||
This article tries to bring structure into the different runtime environments for Python for running python programs or Jupyter Notebooks and their advantages and drawbacks | This article tries to bring structure into the different runtime environments for Python for running python programs or Jupyter Notebooks and their advantages and drawbacks. | ||
For installing packages using pip check out my [[PIP Cheatsheet]] | |||
'''<big><u>''This site is a major work in progress''</u></big>''' | '''<big><u>''This site is a major work in progress''</u></big>''' | ||
== Linux Environments == | == Linux Environments == | ||
Zeile 48: | Zeile 43: | ||
~/venv/finpy/bin/python script1.py | ~/venv/finpy/bin/python script1.py | ||
~/venv/finpy/bin/pip install <package> | ~/venv/finpy/bin/pip install <package> | ||
Further reading in pip: [[PIP Cheatsheet]] | |||
A more comfortable option is to switch to the environment sepcified by its path: | A more comfortable option is to switch to the environment sepcified by its path: | ||
source ~/venv/finpy/bin/activate | source ~/venv/finpy/bin/activate | ||
Zeile 63: | Zeile 60: | ||
=== Miniconda === | === Miniconda === | ||
Further reading: [[Miniconda Cheatsheet]] | |||
=== Known Issues === | === Known Issues === | ||
Zeile 71: | Zeile 68: | ||
[[Kategorie:Python]] | [[Kategorie:Python]] | ||
[[Kategorie:Terminal]] |
Aktuelle Version vom 31. Mai 2025, 13:06 Uhr
This article tries to bring structure into the different runtime environments for Python for running python programs or Jupyter Notebooks and their advantages and drawbacks.
For installing packages using pip check out my PIP Cheatsheet
This site is a major work in progress
Linux Environments
Debian
Python runtine environment on debian is managed by Debian distribution. This means that you can not install additional packages with pip install <package>
. If you try you get the following output:
matt@mypc:~$ pip install matplotlib error: externally-managed-environment × This environment is externally managed ╰─> To install Python packages system-wide, try apt install python3-xyz, where xyz is the package you are trying to install. If you wish to install a non-Debian-packaged Python package, create a virtual environment using python3 -m venv path/to/venv. Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make sure you have python3-full installed. If you wish to install a non-Debian packaged Python application, it may be easiest to use pipx install xyz, which will manage a virtual environment for you. Make sure you have pipx installed. See /usr/share/doc/python3.11/README.venv for more information. note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages. hint: See PEP 668 for the detailed specification.
There are two options to proceed:
Debian Managed Packages
Try and find needed modules in the packages provided by Debian distribution:
apt-get install <package> # Install package aptitude # Interface for searching and installing available packages
Virtual Environment (venv)
Install additional virtual environment as described in the message above, i.e.:
python3 -m venv ~/venv/finpy
Now either issue commands against that environments as follows:
~/venv/finpy/bin/python script1.py ~/venv/finpy/bin/pip install <package>
Further reading in pip: PIP Cheatsheet
A more comfortable option is to switch to the environment sepcified by its path:
source ~/venv/finpy/bin/activate
Example:
matt@mypc:~$ source ~/venv/finpy/bin/activate (finpy) matt@mypc:~$
All subsequent commands will be executed in the context of the active environment, which is now listed in parentheses.
In order to leave the virtual environment again:
matt@mypc:~$ deactivate
Windows Environments
Windows Native
Miniconda
Further reading: Miniconda Cheatsheet
Known Issues
Not all packages seem to work properly. Known issues:
- yfinance.download seems not to work properly on Windows