Execute code written in a virtual environment

Asked 2 years ago, Updated 2 years ago, 55 views

Due to compatibility with some modules, some code was created after creating a virtual environment (32-bit).

By the way, if you run this code as a .py file, an error occurs and abnormal termination occurs.

Instead of making it an exe file, open the virtual environment with the console and run it.When you run py, can't you run it as if it worked under a virtual environment?

python venv

2022-09-20 15:43

1 Answers

There is a way to create a bat file for execution.

Create a batch file named exec_my_script.bat.

c:\work\venv32\script\python.exe  c:\work\python_scripts\my_script.py

When you run the batch file, my_script.py runs on that virtual environment interpreter. (You can change the file name, the location of the script file, and the path of the virtual environment to suit your environment.)


2022-09-20 15:43

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.