Python Virtual Environments - HypatiaOrg/HySite GitHub Wiki

You can use any Python environment you prefer for HySite. However, we tend to test and deploy on the latest releases of Python to get usability and performance upgrades. We also like to use virtual environments, which allow us to keep the HySite environment and packages separate from our other projects.

Python locations

Mac Web install

/usr/local/bin

Mac HomeBrew

/opt/homebrew/bin

Windows web install

This is by the Python version, for example Python 3.13 would be at:

C:\Python313

Pycharm

Uses Settings -> Project: HySite -> Project Interpreter to set the Python environment.

Then select Add Interpreter -> Add Local Interpreter.

We recommend generating a new interpreter from a base that does not inherit any packages.

Then press the OK twice.

Command Line Virtual Environment Setup and Activation

You can also configure the virtual environment for HySite or from the Command Line.

Initial Setup

This step is performed only once to initialize the virtual environment.

Windows and Linux are Tested in Windows PowerShell and OS X Terminal. Some Python installations will need to call python3 instead of python. Check your Python version with python --version if it comes back with 2.7.x, try python3 --version and expect to get 3.x.x.

If you have many Python installations, or if you just downloaded the latest version of Python If you are using Python, replace python with the full path to the Python executable.

python -m pip install --upgrade pip
pip install virtualenv
virtualenv venv

Activating a Virtual Environment

You will need to complete this step every time you want to use the virtual environment.

For a Unix-like environment activation:

source venv/bin/activate

Windows CMD environment activation:

.\venv\Scripts\activate

Windows PowerShell environment activation:

.\venv\Scripts\activate.ps1

Post activation

After activation, the term ail will add a (venv) to the command prompt. At this point You can drop the full patPythonthe Python and pip executables into the terminal, and the python3 command in place of python.

I like to test that everything went as expected with the following:

python --version
pip list

Install HySite requirements

The required Python packages are listed in the backend/requirements.txt

Install from the Command line with:

pip install -r backend/requirements.txt

Update the requirements

pip install --upgrade -r backend/requirements.txt