Installation
If your IT administrator or instructor has created an environment for your course,
with allowed
installed, then you may skip this section.
Preparation
- Open a Linux/macOS terminal or Windows PowerShell, in order to enter the commands given in these instructions.
- Enter
python -V
to check the version you have installed. - If it’s 3.9 or earlier, download and install
the latest version.
However, to use
pytype
(see below) you must install Python 3.10 or 3.11.
Virtual environments
Like any other Python package, allowed
can be installed in your default global environment,
but should preferably be installed in a new or existing virtual environment,
e.g. the one for the course you are studying or teaching.
A virtual environment is a folder with the software you need for one or more projects.
This helps ensuring that you always use the right versions of the right packages for
each project.
- To create a virtual environment, enter
python -m venv path/to/folder
.
The folder you indicate will be created if it doesn’t exist.
For example, if you want to keep all virtual environments in subfolders of ~/environments
,
you would create a new virtual environment for course CS101 with
python -m venv ~/environments/cs101
.
Virtual environments need to be activated in order install software in them.
- To activate a virtual environment enter
source path/to/folder/bin/activate
in Linux/macOSpath/to/folder/scripts/Activate
in Windows.
For our example, it would be source ~/environments/cs101/bin/activate
or
~/environments/cs101/scripts/Activate
.
After activating, the command prompt becomes (folder)
, e.g. (cs101)
,
to show which environment is active.
You must activate a virtual environment every time you want to install further software into it or use the software that is installed in it.
- Once you’re done using a virtual environment,
close the terminal/PowerShell or type
deactivate
.
For more details on why one should use virtual environments and how to use them, we recommend reading the first two sections of Real Python’s tutorial.
Installing
The following instructions will install allowed
and optional additional software
in your current environment, whether it’s the global environment or an active virtual environment.
- Enter
pip install allowed
.
allowed
can check Python code in .py
files and in .ipynb
files (Jupyter notebooks).
If you want to check Jupyter notebooks that have IPython commands
like %timeit
and %run
, then you need IPython.
- Enter
pip show ipython
to check if your current environment has IPython installed. - If you get a message that there’s no such package, then enter
pip install ipython
.
To check method calls of the form variable.method(...)
, allowed
needs
the pytype
package, to know the type of variable
.
pytype
is only available for Linux and macOS.
- Enter
pip show pytype
to see ifpytype
is already installed. - If it isn’t, enter
pip install pytype
.
⇧ Start | Usage ⇨ |