Python is a scripting language.
Scripts are any *.py file executed by an interpreter (like Python’s IDLE). Package is a collection of modules/scripts installed by a package manager.
PATH is an environment variable in Windows. It basically tells the commandline what folders to look in when attempting to find a file. If you didn’t add Python to PATH then you would call it from the commandline like this:
Whereas if you add it to PATH, you can do this:
- Open command prompt
- Enable Python environment (ensure Python installed beforehand): python
- This will show up: >>>
Sample code with Python in Command Prompt:
|>>> print(‘Hello World!’)|
>>> 2 + 57
To exit Python environment: quit() or exit() or ctrl+z (and enter)
|To run *.py (e.g. abc.py),|
|In Command Prompt,|
:: Exit Python environment (if in it)
:: Go to directory of abc.py
:: Type and press enter: python abc.py
:: Open abc.py in IDLE
:: Run (press F5)
To find where python is installed, execute in cmd: where python
|# save as addxz.py|
# when run addxz.py , output will be 7
Check python version: python –version
If version still shows the previous, update to latest @ PATH by Moving Up.
PIP is Python’s package manager.
# Check PIP version pip --version # Download and install packages like TensorFlow and camelcase pip install <packagename> # Using package import camelcase c = camelcase.CamelCase()
# Useful packages list pip install jupyterlab # jupyterlab; launch with: jupyter-lab pip install notebook # classic Jupyter notebook; launch with: jupyter notebook
|single Python version|
|multiple Python version (deprecated @ Python 3.8+ and replaced with venv)|
|Python 2 inclusive|
$ python3 -m venv directory-name-to-create # e.g. python3.6 -m venv example-three-six
$ source name-given/bin/activate
$ rm -r name-given
When the environment is active, any packages can be installed to it via pip as normal (by default, the newly created environment will not include any packages).