Skip to content

Virtualenv Pyhelix Use

​ This document is here for to provide an alternative method to installing pyhelix_tools using virtualenv opposed to pyenv ​ To pull the pyhelix_tools repo from workhelix, we need to install Virtualenv in order to access poetry and add the repository ​

Virtualenv Install

​ 1. Open your terminal and check that you have pip installed and its up to date: pip --version ​ 2. Install virtualenv using pip: pip install virtualenv ​ - On Windows, if you're getting a term is not recognized error:

    - Input: `py -m pip install virtualenv`

​ - On Mac, if you're getting a similar error

    - Input: `python -m pip install virtualenv`

​ - Test installation with command virtualenv --version ​ ​

Virtual Environment Initialization

​ 1. Create a virtual environment:

- Windows: `py -m venv [name of enviro]`

​ - Mac: python -m venv [name of enviro] ​ 2. Activate the enviroment: ​ - Windows: py -m source [enviro name]/Scripts/activate ​ - You may need to install the source package with pip ​ - Mac: python -m source [enviro name]/bin/activate

Pyhelix Pull using Poetry

​ ​ 1. Install poetry using pip: py -m pip install poetry ​ ​ 2. Initialize poetry: py -m poetry init ​ ​ 3. Input: ​ ​ - Package name = [enter package name] ​ ​ - Version = 0.1.0 ​ ​ - Author = [your name] ​ ​ - Define main dependencies? = yes ​ ​ - python = 3.9 ​ ​ - Define development dependencies? = no ​ ​ - confirm generation = yes ​ ​ 4. Add pyhelix_tools: py -m poetry add git+https://github.com/workhelix/pyhelix-tools.git@a7a941c ​ ​ 5. If you'd like to add/change python versions: ​ ​ - First download and install the desired version: ​ ​ - Windows Downloads ​ ​ - MacOS Downloads ​ ​ - In the pyproject.toml file: Adjust the python tool dependency to include the desired python version ​ ​ - Retrieve the path to the python intepreter. Run the following in your script/notebook: ​ ​ ​ import sys print (sys.executable) ​ ​ ​ - In your terminal input: py -m poetry env use [path to python version] ​ ​ - Windows typical path: C:\Users\[user name]\AppData\Local\Programs\Python\[python version]\python.exe ​ ​ - Below is Makefile syntax to automate the python dependency change ​ ​ ```

        .ONESHELL:
        .DELETE_ON_ERROR:

​ .PHONY: versions_py ​ versions_py : @set "python_versions=" @for /f "tokens=*" %%i in ('py -0p') do @(set "python_versions=!python_versions!%%i") @echo Available Python versions: %python_versions% @set /p desired_version="Enter the Python version you want to use (No periods eg 311): " @for %%i in (%python_versions%) do @(if %%i == %desired_version% (set "python_exe=%%~$PATH:i")) @if not defined python_exe (echo "Desired version not found. Exiting..." & exit /b 1) @%python_exe% -m venv venv @echo "Virtual environment created successfully." @exit /b ```