Managing Python Virtual Environments with pyenv
The Most Basic Step-By-Step Guide
Managing Python Virtual Environments with pyenv
The Most Basic Step-By-Step Guide
Photo by Riku Lu on Unsplash
Installation:
pip install virtualenv
Get all Python versions from pyenv:
pyenv versions
Create a virtual-env with whatever name you want from the desired python version:
pyenv virtualenv 3.7.12 shashwat-api-svc
How to activate this new environment for our repository?
Go to the repository.
Example Repo: /Users/shashwatkumar/Desktop/shashwat-api-svc
Use:
pyenv activate shashwat-api-svc
A common issue which we see here is:
Failed to activate virtualenv. Perhaps pyenv-virtualenv has not been loaded into your shell properly. Please restart current shell and try again.
This happens if pyenv has not been configured properly.
Alternatively, using:
source /Users/shashwatkumar/.pyenv/versions/3.7.12/envs/shashwat-api-svc/bin/activate
works.
Note: Always do ***pip install poetry*** in the virtual environment created, or else it uses the main poetry.
If you haven’t seen: How To Install Pyenv, just click
In case we are meeting for the first time, come over here, it’ll be worth the roller coaster of articles that are gonna come up in the next few weeks.
Use this to get to know more about me — https://linktr.ee/shashwat_writes
메타데이터
- post_id
- 4b9caa36a8f1
- slug
- managing-python-virtual-environments-with-pyenv-4b9caa36a8f1
- url
- https://medium.com/@shashwatwrites/managing-python-virtual-environments-with-pyenv-4b9caa36a8f1
- canonical_url
- https://medium.com/@shashwatwrites/managing-python-virtual-environments-with-pyenv-4b9caa36a8f1
- author_url
- https://medium.com/@shashwatwrites
- status
- ok
- fetched_at
- 2026-08-04 23:03:49