python virtual environment setup (venv) – from command line
create python virtual environment from command line
https://www.electronics-engineering.com/python-virtual-environment-setup-venv-from-command-line


To prevent conflicts, utilizing a virtual Python environment offers a seamless solution. This involves setting up a local directory, typically named ‘venv’, where all necessary libraries, along with their dependencies, are stored.
Begin by creating an empty folder corresponding to your project’s name and navigating into it using the ‘cd’ command:
mkdir project_name
cd project_name/usr/bin/python3 -m venv venvsource venv/bin/activateNow, you’re within the virtual Python environment, ready to install required libraries. It’s advisable to update ‘pip’ beforehand:
pip install --upgrade pipProceed to install the necessary libraries, such as:
pip install pillow
pip install torch torchvision
pip install opencv-python
pip install pandasThese commands will also handle the installation of any dependencies.
To exit the virtual environment, simply type:
deactivateNotably, PyCharm typically operates within a virtual environment by default, eliminating the need for manual setup. You can simply open PyCharm from the created project folder. Once the initial indexing is complete, you can seamlessly develop your project within PyCharm.
To further streamline your development process, it’s worth noting that PyCharm seamlessly integrates with virtual environments. Upon opening PyCharm from the project folder, it automatically recognizes and utilizes the virtual environment established earlier. This eliminates the need for manual configuration, allowing you to dive straight into your project without additional setup steps.
In conclusion, leveraging virtual Python environments is a practical approach to mitigate conflicts and manage project dependencies effectively. By encapsulating project-specific libraries and their dependencies within a designated environment, you ensure consistency and reproducibility across different projects and collaborators. Whether you’re working directly within the virtual environment or using PyCharm’s seamless integration, adopting this practice enhances the efficiency and reliability of your Python development workflow.






Hi, I am the author of “python virtual environment setup (venv) – from command line”. Questions, doubts, error reports and requests for more detail are all welcome: write them below and I will answer. You can also rate the page with the stars at the top of the article.