Python Setting Up Your Environment - firemodels/fds GitHub Wiki
These notes are based on the Python - Installing Packages documentation. Here, we will focus on setting up a minimal environment for running the python scripts used in our continuous integration (CI) framework Firebot. The following instructions should work for macOS and Linux. For Windows, please follow the same basic process, but look to the aforementioned documentation.
Requirements
First, make sure you have Python version 3.7 or higher installed.
$ python --version
Python 3.12.2
If you get an error, or have a version below 3.7, talk to your system administrator or attempt the installation yourself (see the next section). Installation instructions for Python can be found here.
Installing Python (if necessary)
The following is based on this thread. If the command above does not return a version of Python greater than 3.7, then try:
(macOS)
$ brew update
$ brew install python
$ brew info python
...
==> Caveats
Python has been installed as
/opt/homebrew/bin/python3
Unversioned symlinks `python`, `python-config`, `pip` etc. pointing to
`python3`, `python3-config`, `pip3` etc., respectively, have been installed into
/opt/homebrew/opt/[email protected]/libexec/bin
This last line is useful. Copy this and add it to your PATH in your ~/.bash_profile.
export PATH="/opt/homebrew/opt/[email protected]/libexec/bin:$PATH"
Now "python" and "python3" should behave the same way.
(Ubuntu Linux)
Follow these instructions.
(Enterprise Linux)
Follow these instructions.
[!NOTE] If Python 2.7 is still active on your Linux system, the preferred way to point "python" to "python3" is to simply use an alias, as discussed here.
(Windows)
Install Python from python.org.
If you plan to use the Spyder IDE, install Python 3.11 or earlier, because Python 3.12+ has a DLL compatibility issue with NumPy versions earlier than 2.0 (this will be addressed in a future update).
Make sure that python.exe is added to your system PATH.
Why Use a Python Environment?
The simple answer to this question is that environments avoid the "version hell" dilemma. All the packages that you import, and their dependencies, must be compatible with the version of Python you are using to process your scripts. The only sane way to accomplish this is with a package manager. There is no need for a commercial package manager, pip (preferred installer program) works great, and if you include "ipython" in your requirements.txt file (which we do), then you will have the IPython interactive shell and Jupyter notebooks available.
Setting Up Your Environment
One-time setup
You only have to do this step once, not each time you use Python. Subsequently, you either activate your environment on startup or whenever you decide (as discussed below).
-
first download FDS following:
👉 FDS Compilation Guide -
Open a terminal (or command prompt) and go to the top level of the FDS repository and into the Utilities/Python subdirectory.
$ cd <path-to-repo>/fds/Utilities/Python
$ source ./setup_python_env.sh
# For Windows: call setup_python_env.bat
Next-time onwards
Activate the FDS python environment with
$ source <path-to-repo>\fds\.github\fds_python_env/bin/activate
# For Windows: call <path-to-repo>\fds\.github\fds_python_env\Scripts\activate
You will notice your prompt now has the environment name prepended.
(fds_python_env) username@host <where ever you are> $
For Linux and MacOS, you can add the source command to your terminal startup script (~/.bash_profile on macOS or ~/.bashrc on Linux). Just make sure the path to the environment is correct. For example, if your repo path is ~/GitHub/firemodels/ then add this to your startup.
# Start Python environment
source ~/GitHub/firemodels/fds/.github/fds_python_env/bin/activate
Deactivating Your Environment (optional)
If you no longer want to use this environment, simply deactivate it by typing
$ deactivate
and you will see the prompt return to normal.
Using Spyder IDE with FDS python environment (optional)
Follow this link: 👉 Spyder IDE Setup for FDS Python Utilities