使用Python文档创建虚拟环境
我对命令行的使用非常陌生。我正在使用 python 3.7.2、Bash 和 VSCode 集成终端。我正在尝试使用 venv 和以下 python 文档创建虚拟环境:
https://docs.python.org/3/tutorial/venv.html#creating-virtual-environments
使用的命令是这个:
$ python3 -m venv test-env
我得到:
bash: python3: command not found
后来我在 stackoverflow 中找到了类似的答案邮政:
如何创建和激活虚拟使用 bash 命令在 Windows 10 中的环境
我使用命令:
py -m virtualenv test-env
我得到了这个:
No module named virtualenv
我对使用命令行非常陌生,所以我真的不知道发生了什么以及如何解决它。
I am very new at command line usage. I am using python 3.7.2, Bash and VSCode Integrated Terminal. I am trying to create a virtual environment using venv and following python documentation:
https://docs.python.org/3/tutorial/venv.html#creating-virtual-environments
The command to use is this one:
$ python3 -m venv test-env
and I get:
bash: python3: command not found
Later I have found a similar answer in an stackoverflow post:
How to create and activate virtual environment in windows 10 using bash command
And I use the command:
py -m virtualenv test-env
and I get this:
No module named virtualenv
I am very new using the command line so i don´t really know what is going on and how to work it around.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您好,我可以看到您正在使用两种不同的工具来创建您的环境。
它们是“venv”和“virtualenv”。
Venv 是 Python 安装中已附带的库。
Virtualenv 是一种外部环境。
我之前也遇到过同样的问题,解决方案非常简单。
我建议您坚持使用 venv,因为它工作得很好,而且您不需要做额外的工作来安装外部库。
因此,为了解决您的问题,Bash Shell 会告诉您尚未找到命令 Python3。
所以尝试一下:
python -m venv test-env
有时Python文档不够准确,我知道当你开始使用命令时,sintax的准确性非常重要。
Hi i can see that you are using two different tools to create your environment.
Those are "venv" and "virtualenv".
Venv is a library that already comes with your python installation.
Virtualenv is an external one.
I had the same problem before and the solution is very simple.
I recommend you to stick with venv because it works pretty ok and you don´t need to do extra job installing external libraries.
So for solving your problem the Bash Shell is telling you that the command Python3 has not been found.
So try instead just:
python -m venv test-env
Sometimes Python documentation is not accurate enough and I know when you start using commands, accuracy in the sintax is extremely important.
尝试以下步骤,它会对您有所帮助:
您收到如下错误:
虚拟环境未成功创建,因为ensurepip未创建
可用的。在 Debian/Ubuntu 系统上,需要安装 python3-venv
使用以下命令进行打包。
注意:您可以将此文件夹命名为“bhandari”;您喜欢的任何名称(标准做法是将其命名为“env”...)
之后,我们可以安装任何与系统其余部分隔离的东西......
Try this steps,it'll helped you:
You got error like :
The virtual environment was not created successfully because ensurepip is not
available. On Debian/Ubuntu systems, you need to install the python3-venv
package using the following command.
Note: you can named this "bhandari" folder; anyname you like( Standard practice is to name it "env" ...)
After this, we can install anything that will be isolated from the rest of the system....