Python Forum
Help with creating folder and "virtual environment" - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Help with creating folder and "virtual environment" (/thread-41798.html)



Help with creating folder and "virtual environment" - AudunNilsen - Mar-20-2024

Hi

I want to make use of GitHub-programs, and so I downloaded a bunch of Python-tools.

When I run this command in "Python 3.12", which looks like CMD to me, I get a syntax error.

"To create a virtual environment, Python supplies a built in venv module which provides the basic functionality needed for the virtual environment. Running the command below will create a virtual environment named "openai-env" inside the current folder you have selected in your terminal / command line:

python -m venv openai-env"

First of all, the instructions said nothing about "selecting" a folder, and I have no idea how to do that, so maybe that´s what´s going on. It says it´s included in the program, so..

Any clue?


RE: Help with creating folder and "virtual environment" - deanhystad - Mar-21-2024

This command:
python -m venv openai-env
Is run in a shell (like CMD or powershell in windows), it is not run inside a python shell.

Running this command will create a folder named openai-env in the current working directory. The folder will contain a partial copy of your Python 3.12 distribution.

To use the virtual environment it has to be activated. This can be done different ways, and these are probably discussed in the same document that describes how to make a virtual environment. I do all my python development using Visual Studio Code (or VSCode). When I start a new Python project I create a virtual environment that is associated with the project. When I open the project in VSCode, VSCode automatically activates the virtual environment. Most IDE's doe something similar. You can also activate your virtual environment by executing the activate.bat file in (for your example) openai-env\Scripts.