Python Forum
Project structure with a virtual environment
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Project structure with a virtual environment
#1
[output]Hello to all,
Could you help me resolve the following issue: I'm having a project vscode where i created a folder containing a virtual environment and i added a python script that i'm trying to run, for reasons that i don't understand i can't run the script even after downloading the required packages in the project (after I activated the virtual environment). How should i structure the project to be able to run the script? Thank you for your help.
This how I structured the project (called trading):
1. virt (this the virtual environment folder)
2. __init__.py (an empty python file, which placed below the virt folder - not sure i should have put this file in there)
3. my_script.py (the script i'm trying to run, which placed below the __init__.py file, hence below the virt folder)
   
Reply
#2
You most see down in left corner that it run interpreter from virtual environment.
Add this to see what interpreter that is used.
import sys # See that use python.exe from virtual enviroment run print(sys.executable)
Here a screenshot from a quick test.
[Image: f5kkJo.png]
See that down in left corer that it point to my test_env,you can left click and choice right environment.
When i run code see that it use python.exe from environment.

How i did make environment from command line,i use cmder and start VSCode with code .
[Image: EBh03J.png]

So if i do:
(test_env) G:\div_code\test_env λ pip install pandas-datareader Collecting pandas-datareader .....
It will work from VSCode and command line.
(test_env) G:\div_code\test_env λ python Python 3.10.0 (tags/v3.10.0:b494f59, Oct 4 2021, 19:00:18) [MSC v.1929 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import pandas_datareader as pdr >>> >>> pdr <module 'pandas_datareader' from 'G:\\div_code\\test_env\\lib\\site-packages\\pandas_datareader\\__init__.py'> >>> exit() >>> exit()
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Venv - Python Virtual Environment on Raspberry Pi DanneA 4 1,718 Jul-02-2025, 05:41 PM
Last Post: Larz60+
  Start Idle in a virtual environment Pedroski55 8 3,296 Jun-02-2025, 05:53 AM
Last Post: Pedroski55
  I cannot create a virtual environment on visual studio code using python Willem_Aucamp316 2 12,166 Nov-27-2024, 02:20 PM
Last Post: menator01
  How to enable Matplotlib within virtual environment? tetris_theMovie 1 1,942 Oct-11-2024, 09:56 AM
Last Post: christie2
  Need help setting up trusted root ca in virtual environment dstempfley 0 1,860 May-31-2024, 03:14 PM
Last Post: dstempfley
  Python Project Structure for Modularity and Reusability with Multiple Entry Points b19wh33l5 0 2,507 Apr-24-2024, 12:21 PM
Last Post: b19wh33l5
  Help with creating folder and "virtual environment" AudunNilsen 1 1,577 Mar-21-2024, 04:41 AM
Last Post: deanhystad
  Installing python packages in a virtual environment Led_Zeppelin 1 2,374 Aug-15-2023, 08:18 PM
Last Post: deanhystad
  Problem with virtual environment standenman 2 3,612 Feb-23-2023, 07:09 PM
Last Post: standenman
Question Virtual Environment (using VS Code) Ashcora 4 109,984 Feb-15-2023, 07:17 PM
Last Post: snippsat

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020
This forum uses Lukasz Tkacz MyBB addons.
Forum use Krzysztof "Supryk" Supryczynski addons.