Setup python environment - AST-Course/AST5110 GitHub Wiki

Setup python environment

Diverse options are available to set up the environment, such as Mamba, Miniconda, etc. Below, for convenience, the environment is set up based on using Miniconda, which is a lightweight alternative to Anaconda. To set up the Python environment for the AST5110 course, follow these steps:

  1. Create a New Environment: After installing Miniconda, use Conda to create a new environment specifically for this course. This helps manage dependencies and avoid conflicts with other projects. Run the following commands in your terminal:

    mamba create --name ast5110_course python=3.12
    mamba activate ast5110_course
  2. Install Required Packages: Once the environment is activated, install the necessary packages. You should have a requirements.txt file provided for the course. Install these dependencies using Mamba by running:

    mamba install --file requirements.txt
  3. Install Course-Specific Files: Navigate to the directory of nm_lib, where you should find the pyproject.toml files. Install the course-specific library by running:

    pip install -e .
  4. Import the Course Library: To start using the course library, import it into your Python script or interactive environment, for instance, as follows:

    from nm_lib.nm_ex import nm_lib_ex_1 as nm1

Note: if the environment is not properly activated or the module is not installed under the environment used, the module will not be successfully imported.

Additional Dependencies

  • Pytest: For running tests in Continuous Integration/Continuous Deployment (CI/CD), install pytest.

  • Pre-commit: For maintaining code quality, use pre-commit. To clean the code according to the defined pre-commit hooks, run the following:

    pre-commit run -a

These steps will set up a dedicated Python environment with all the required dependencies for your AST5110 course, ensuring a smooth and conflict-free experience.

⚠️ **GitHub.com Fallback** ⚠️