![]() Now, anyone can create the same environment by running the pip install -r requirements.txt command to reinstall the packages.Īnother way to activate the environment is by running source myvenv/bin/activate (Linux/macOS) or myv env\Scripts\Activate.ps1 (Windows). In the terminal of the activated virtual environment, we can run:Īs we can see, in our folder, there is the requirements.txt file as well as the myenv folder. ![]() Using the pip freeze command we can generate the requirement.txt file based on the libraries that we installed in our virtual environment. Then run Terminal: Create New Terminal (Ctrl Shift `)) from the Command Palette, that opens a new python terminal and in parallel it activates the virtual environment.Ĭonfirm that that new environment is selected (Hint: look at the blue status bar at the bottom of the VS code) and then update the pip in the virtual environment:įinally, let’s install the pandas and flask libraries Then, select the Python: Select Interpreter command and then the environment that we created “ myenv“: I can only see 'Python>Testing:Pytese path' below 'Python:Poetry Path'. Then In VS Code, open the Command Palette ( View > Command Palette or (Ctrl Shift P)). In the video, I can see the 'Python:Python Path' below 'Python:Poetry Path' with following information 'Python:Python Path Path to Python, you can use a custom version of Python by modifying this serring to include the full path' However, I didn't find Python Path. Then, we can open the folder “ venv_example” from the VS Code using the File > Open Folder command. Sudo apt-get install python3-venv # If needed Within this folder, we can create a virtual environment called “ myvenv” by running the following command: Create a Project Environmentįor this example, we call our project “ venv_example“, and we have created a folder with the same name. Finally, it is less risky to mess with your other projects when you work with virtual environments. This is because with the virtual environments, the project is reproducible, and we will need to install only the required libraries as stated in the requirements.txt. Moreover, it is more efficient to work with the necessary only libraries. When we work on a Data Science project, which can include a Flask API, it is better to have full control over the libraries used in the project. In this post, we will provide you a walk-through example of how to work with VS Code and virtual environments. We are pleased to announce that the May 2021 release of the Python Extension for Visual Studio Code is now available. ![]() We have provided examples of how to work with conda environments.
0 Comments
Leave a Reply. |