简体   繁体   English

在 Windows 上为 Python 设置虚拟环境

[英]Setting up Virtual Environment for Python on Windows

I'm having issues with setting up the virtual environment on my Windows 10 computer.我在 Windows 10 计算机上设置虚拟环境时遇到问题。 I suspect that it might have to do with the GNU C compiler I have installed but I'm not sure.我怀疑它可能与我安装的 GNU C 编译器有关,但我不确定。

So first I did: python3 -m venv env This created the following folders:所以首先我做了: python3 -m venv env这创建了以下文件夹:

  • bin (includes the activate file — does not have the ' .bat ' extension — and the active.ps1 file) bin (包括激活文件 - 没有 ' .bat ' 扩展名 - 和active.ps1文件)
  • include( empty )包括( empty
  • lib ( pip , setuptools , etc) and the folder libpipsetuptools等)和文件夹
  • pyvenv.cfg

In pyvenv.cfg :pyvenv.cfg

home = C:\msys64\mingw64\bin #Not the path to my python compiler, it's my c compiler
include-system-site-packages = false
version = 3.9.7

So naturally, I looked at several tutorials to activate venv and when I try their method for windows computers in the cmd prompt it says that the path or command does not exist.所以很自然地,我查看了几个激活 venv 的教程,当我在 cmd 提示符中尝试 windows 计算机的方法时,它说路径或命令不存在。

Furthermore, in the active file in the first line of the code, it says it must be used from bash.此外,在代码第一行的active文件中,它说它必须从 bash 使用。

How do I fix this?我该如何解决?

Had almost the same problem, few mounths ago.几乎相同的问题,几山前。 For me problem was that Python compiler was not in PATH.对我来说,问题是 Python 编译器不在 PATH 中。 Try checking if Python is in environment variables - System (Control Panel)>> Advanced system settings>> Environment Variables尝试检查 Python 是否在环境变量中 - 系统(控制面板)>>高级系统设置>>环境变量

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM