Skip to content

Instantly share code, notes, and snippets.

@joeld1
Last active April 22, 2023 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joeld1/c48fda0c312e1ae0715b73877d50f131 to your computer and use it in GitHub Desktop.
Save joeld1/c48fda0c312e1ae0715b73877d50f131 to your computer and use it in GitHub Desktop.
Create Conda Virtual Envs for your Poetry Projects (Ideal for Mac M1 users)
#!/bin/bash
ENV_NAME=$1
PYTHON_VERSION=$2
CONDA_BASE=$(conda info --base)/"etc/profile.d/conda.sh"
CONDA_ENV_PATH=$(conda info --base)/"envs/$ENV_NAME"
echo "$CONDA_BASE"
echo "$CONDA_ENV_PATH"
echo yes | conda create -n "$ENV_NAME" python="$PYTHON_VERSION";
conda activate "$ENV_NAME"
echo yes | python -m pip install --upgrade pip setuptools wheel;
echo yes | conda install notebook ipykernel;
ipython kernel install --user --name $ENV_NAME --display-name $ENV_NAME
poetry config virtualenvs.path "$CONDA_ENV_PATH" --local
poetry config virtualenvs.create 0 --local
poetry config virtualenvs.in-project 0 --local
@joeld1
Copy link
Author

joeld1 commented Mar 15, 2021

To run, ensure the following:

  • Anaconda is installed
  • Poetry is installed
  • chmod u+x 'conda_poetry.sh' has been applied
  • Lastly, execute the script as follows: source conda_poetry.sh "my_env_name" "3.9"
  • If it's not run using source conda_poetry.sh, the script will be executed in a separate sub-process with different variables

@mslmn
Copy link

mslmn commented Apr 22, 2023

how do I run poetry with this script?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment