无法创建虚拟环境 [英] cannot create a virtual environment
问题描述
我最近将操作系统更改为Windows 10并设置了anaconda3.问题是在Anaconda Navigator(位于环境"选项卡中)中,在设置名称和名称后,单击创建"按钮以创建新的虚拟环境.python版本(到3.7作为唯一选项),将不会创建venv,而是出现此错误:
I've recently changed my OS to windows 10 and setup anaconda 3. The problem is that in Anaconda Navigator (in the Environment tab) when clicking on the create button to make a new virtual environment, after setting a name and the python version (to 3.7 as the only option), the venv won't be created, instead, I get this error:
CondaHTTPError: HTTP 000 CONNECTION FAILED for url <https://repo.anaconda.com/pkgs/main/win-
64/current_repodata.json><br>Elapsed: -<br><br>An HTTP error occurred when trying to retrieve this
URL.<br>HTTP errors are often intermittent, and a simple retry will get you on your way.<br><br>If
your current network has https://www.anaconda.com blocked, please file<br>a support request with your
network engineering team.<br><br>'https://repo.anaconda.com/pkgs/main/win-64'<br>
尽管我可以在浏览器中打开此文件: https://repo.anaconda.com/pkgs/main/win- 64/current_repodata.json
Although I can open this file in my browser: https://repo.anaconda.com/pkgs/main/win- 64/current_repodata.json
另一方面,当我尝试按照以下步骤制作虚拟环境时:
On the other hand, when I try to make a virtual env following these steps:
mkdir projects
cd projects
mkdir drdr
cd drdr
python -m venv ./venv
然后当我如下激活venv时:
Then when I activate the venv like below:
venv\Scripts\activate.bat
我得到:
(venv) (base) C:\Users\shima\projects\drdr>
我不知道什么是(venv)(基础).我是否应该意识到它已激活.即使当我尝试通过以下代码激活我的venv时:
which I don't know what is (venv) (base). Should I realize it activated or not. Even when I try to activate my venv by the code below:
conda activate venv
我收到此消息:
Could not find conda environment: venv
此外,制作venv之后,无论我选择在venv文件夹中的哪个文件夹,都想将其导入到导航器中,都无法导入
Also, after making the venv, when I want to import it in my navigator no matter I choose which folder inside my venv folder, I can't import it
顺便说一句,检查防火墙是否允许来自anaconda的流量,我无法在允许的应用程序列表中找到anaconda,然后尝试将其添加到该列表中,我不知道应该在anaconda文件夹中添加哪个文件夹
By the way, checking whether firewall allows traffic from anaconda, I cannot find anaconda in the list of allowed apps and trying to add it the list, I don't know what folder inside anaconda's folder I should add
我不知道为什么会发生此问题,并且无法在anaconda文档中找到答案,也无法在StackOverflow中找到其他问题,因此,我真的很感激此问题.
I don't know why this problem has happened, and couldn't find an answer in anaconda documents or others questions here in StackOverflow, so I really appreciate any help in this issue.
非常感谢!
推荐答案
python -m venv ./venv
您正在将 conda
虚拟环境与 virtualenv
虚拟环境混合在一起,因此造成了所有混乱:
you are mixng conda
virtual environments with virtualenv
virtual environments, hence all the confusion:
(venv) (base) C:\Users\shima\projects\drdr>
看起来很奇怪,因为确实如此.您处于conda的 base
环境中,但是已激活一个称为 venv
does look strange, because it is. You are in the base
environment of conda, but have activated a virtualenv environment called venv
找不到conda环境:venv
Could not find conda environment: venv
没有conda环境 venv
,您从未创建过该环境.
there is no conda enviroment venv
, you have never created one.
简而言之:
使用conda时,请勿使用virtualenv,而应使用
When using conda, don't use virtualenv, insted use
conda create -n venv
创建虚拟环境并
conda activate venv
激活它
这篇关于无法创建虚拟环境的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!