Overview
Have you ever found yourself wondering how to use Python’s venv virtual environment after not touching it for a while? Python’s charm is that it allows you to code quickly and easily, but if setting up your development environment is a hassle, it defeats the purpose.
With that in mind, while it’s true that using commands directly is more powerful, I’ve created a tool that allows you to handle the basics with ease. Feel free to use it if you’d like.
Download
GoroVenvManager-20240904.zip
Source
https://github.com/goro131241D/GoroVenvManager.git
The source code, for some reason, fails to compile the first time. I’m using ROBOCOPY in the pre-build events, and it causes a failure the first time, but it compiles successfully on the second try. It’s probably something like a timeout issue. If anyone knows what’s causing this, I’d appreciate it if you could leave a comment.
The concern is that I’ve only been able to test it on Windows 10.
Also, if you find it difficult to use, or if there are any issues with the behavior, please leave a comment and I’ll do my best to address it (as much as I can).
Usage
[Tabs]
- Create Venv: Create a Venv environment and copy the template.
- Global Version: Set the global version.
- Local Version: Set the local version.
- Install: Install Python.
- pyenv: Install the pyenv-win environment.
- Settings: Configuration.
- Usage: Instructions.
[About Venv Environment]
The Venv environment is created in the .venv folder. Although users can usually choose the location freely, this is pre-determined.
Version management is handled using pyenv-win, and virtual environments are created using Venv. These two tools are used together.
[Procedure]
- Set the language in the Settings tab and restart the tool.
- For the first time, set up the pyenv-win environment in the “5. pyenv” tab.
- Install Python and make it available using the “4. Install” tab.
- Set the global version in the “2. Global Version” tab. “Global” means it can be used regardless of the folder.
- Set the local version in the “3. Local Version” tab. “Local” means it is valid only within the folder.
- Create a Venv environment in the specified folder and copy the specified template folder using the “Create Venv” tab.
[Version Confirmation]
You can check the installed versions using `pyenv versions`.
If there is no active version set: Nothing will be displayed, or the downloaded versions will be shown.
If the global version is active: `pyenv version` will display the version number followed by the location of the `version` file within the `.pyenv` folder. Example: “* 3.12.5 (set by C:\Users\UserName\.pyenv\pyenv-win\version)”
If the local version is active: the version number will be followed by the location of the `.python-version` file.
Example of a Local Version Being Set
PS C:\Users\UserName\TestFolder> pyenv versions
3.11.9
3.12.3
* 3.12.4 (set by C:\Users\UserName\TestFolder\.python-version)
3.12.5
The .python-version file has been created in the local folder. It can also be created in a parent folder, in which case it will be effective for all folders under that parent folder.
Example of a Global Version Being Set
PS C:\Users\UserName\TestFolder> pyenv versions
3.11.9
* 3.12.3 (set by C:\Users\UserName\.pyenv\pyenv-win\version)
3.12.4
3.12.5
The version file is recorded in the version file inside the .pyenv folder. The .pyenv folder contains the necessary files for pyenv and the installed Python versions.
Example Where Neither Global Nor Local Version is Set
PS C:\Users\UserName\TestFolder> pyenv versions
3.11.9
3.12.3
3.12.4
3.12.5
Nothing is displayed next to the versions. In this case, please note that Python installed via pyenv-win cannot be used.
[Details]
Version management and Venv environment creation are done using pyenv-win and python -m venv .venv.
This tool does not directly manage versions or virtual environments.
You can also perform these tasks directly from the command prompt without using this tool.
This is a simple support tool. Messages from the commands are displayed on the screen, so please check the messages to confirm if installations, etc., were completed successfully.
The input data type is not checked. Please enter the correct data.
1. Create Venv: Create a Venv environment and copy the template
Select the folder to create the Venv environment, select the template, and click the “Create” button to create the Venv environment.
A template is a collection of useful files when programming.
The templates are in the templates folder in the folder where this program is stored.
You can create your own template by changing the folder name or the files inside it.
Note that it can only be created in an empty folder, considering overwriting. If there are necessary files, please move them elsewhere before creating.
2. Global Version: Set the global version
The global version is a version that can be used regardless of the folder.
Set and use a convenient version.
Since there are frequent version updates, download and use the new version each time.
3. Local Version: Set the local version
The local version is a version that is valid only within the folder.
When developing, you may need to change the version for each project.
This is when you use it.
The selectable versions will be displayed when you either choose a folder by clicking the “Select” button or press the “Set” button.
4. Install: Install Python
Use this when there is a version update or when you want to use a special version.
There is no uninstall function in this tool. Please do it from the command.
5. pyenv: Install the pyenv-win environment
Use this the first time and when upgrading pyenv-win.
When upgrading, delete the .pyenv folder in the user folder and then run it.
Note that in this case, the installed Python versions will also be deleted.
Alternatively, you can update from the command.
An update feature might be added in the future.
6. Settings: Configuration
Set the language in the Languages option. It will take effect after restarting the tool.
Set the base folder in the BaseFolder option to make folder selection operations easier.
7. Usage: Instructions
【Issues】
- When the Python version that can be used to create a venv is not set, an error occurs, but it is difficult to recognize.
- It does not support updates of pyenv-win.
- Some parts that should have flexibility in settings are hard-coded.
- It is difficult to distinguish whether it is set locally or globally.
There may be other improvements needed, but please bear with us.
[License]
This tool is licensed under the GNU General Public License v3.0 (GPL-3.0).
This means anyone can freely use, modify, and redistribute it, but any modified software must be released under the same license.
For details, please see the following URL:
https://www.gnu.org/licenses/gpl-3.0.html
Commnts