This project automates the installation of pyenv on Windows, allowing users to manage multiple Python versions seamlessly. The provided PowerShell script simplifies the setup and configuration of pyenv, setting environment variables and handling version management.
This project provides a PowerShell script to automate the installation of pyenv-win, a Python version manager for Windows. It simplifies setting up pyenv, handling multiple Python versions, and integrating with virtual environments.
- Automates the download and installation of pyenv-win.
- Sets environment variables for pyenv automatically.
- Adds pyenv to the system PATH for seamless access.
- Creates a virtual environment for Python projects and integrates it with VSCode, etc....
-
Download the PowerShell Script:
-
Run the install_pyenv.bat:
- The script will do this :
- Download the pyenv repository.
- Extract the pyenv files to your .pyenv folder.
- Set environment variables for pyenv.
- Add pyenv directories to the PATH variable.
- Unblock the pyenv script if necessary.
- The script will do this :
-
Restart PowerShell:
- After the script finishes, restart your PowerShell terminal to apply the changes.
If you prefer to manually set up pyenv or need more control, follow these steps:
-
Download pyenv-win:
- Go to the pyenv-win GitHub repository and follow the instructions there.
-
Create
.pyenv
Directory:- Manually create a
.pyenv
folder in your home directory.
- Manually create a
-
Set Environment Variables:
- Set the
PYENV
andPYENV_HOME
environment variables to the pyenv installation path.
- Set the
-
Add pyenv to PATH:
- Add the
bin
andshims
directories of pyenv to the system PATH.
- Add the
To set the global Python version:
pyenv global 3.13.2 # Or any version of your choice
This sets the default Python version for your system.
To set a local Python version for a specific project:
-
Navigate to your project folder:
cd (your project path)
-
Set the local Python version:
pyenv local 3.12.2 # Or any version of your choice
To create and activate a virtual environment for your project:
-
Navigate to your project folder:
cd (your project path)
-
Create the virtual environment:
python -m venv .venv
-
Activate the virtual environment:
.\.venv\Scripts\activate
To use pyenv in VSCode, follow these steps to configure the terminal to activate the virtual environment:
-
Open VSCode Command Palette:
- Press
Ctrl + Shift + P
in VSCode. - Type and select
Open Workspace Settings (JSON)
.
- Press
-
Modify JSON Settings:
- Add the following configuration to your
settings.json
file:{ "python.terminal.activateEnvironment": true }
- Add the following configuration to your
-
Restart VSCode:
- After saving the settings, restart VSCode to ensure the changes take effect.
This project utilizes the pyenv-win repository to manage Python versions on Windows. Special thanks to the contributors of pyenv-win for their work.
- Repository: pyenv-win on GitHub
- Creator: pyenv-win Contributors
With this automation script and manual setup guide, you can efficiently manage multiple Python versions on your Windows system. Enjoy working with pyenv and simplifying your Python development workflows!