简体   繁体   English

如何从 windows 命令提示符在虚拟环境中运行 python 程序?

[英]How do I run a python program in a virtual environment from windows command prompt?

I created a virtual environment for a Python program using PyCharm.我使用 PyCharm 为 Python 程序创建了一个虚拟环境。 I can run the program just fine straight from PyCharm terminal but when I try to run it from windows command prompt I get an error because some modules in the program are only installed in the virtual environment.我可以直接从 PyCharm 终端很好地运行该程序,但是当我尝试从 windows 命令提示符运行它时,我收到一个错误,因为程序中的某些模块仅安装在虚拟环境中。

So my question is: how do I run a Python program that is in a virtual environment from the command prompt?所以我的问题是:如何从命令提示符运行虚拟环境中的 Python 程序?

$ cd your_project
$ ./activate.bat
$ python helloworld.py

Explaination: virtualenv should create a.bat file in your project root directory.说明:virtualenv 应该在你的项目根目录中创建一个 .bat 文件。 To run it, activate the virtual env first then run the python command.要运行它,首先激活虚拟环境,然后运行 python 命令。

I think you have to look after switching virtual environment on windows我认为您必须照顾在 windows 上切换虚拟环境

may be this will help [ https://towardsdatascience.com/manage-your-python-virtual-environment-with-conda-a0d2934d5195][1]可能这会有所帮助[ https://towardsdatascience.com/manage-your-python-virtual-environment-with-conda-a0d2934d5195][1]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在 Windows 7 的命令提示符中运行 Python 程序? - How do I run a Python program in the Command Prompt in Windows 7? 如何从Windows命令提示符运行远程Python程序 - How to run a remote Python program from Windows command prompt 如何从 Windows 10 命令提示符激活虚拟环境 - How to activate virtual environment from Windows 10 command prompt 如何在Windows10中从bash提示符运行python'__main__'程序文件? - How do I run python '__main__' program file from bash prompt in Windows10? 如何在Windows 10中从常规命令提示符处激活python anaconda并运行脚本 - How do I activate python anaconda and run script from regular command prompt in Windows 10 我无法从命令提示符运行 Sublime Text 3 Python 程序 - I cannot run a Sublime Text 3 Python program from Command Prompt 如何在 Windows 7 的虚拟环境中运行 py 文件? - How do I run a py file inside a virtual environment on Windows 7? Python,尝试从命令提示符运行程序 - Python, trying to run a program from the command prompt 尝试从命令提示符运行 Python 程序 - Trying to run Python program from command prompt 如何从命令提示符运行 Pygame Zero 程序? - How can I run a Pygame Zero program from the Command Prompt?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM