【发布时间】:2021-02-26 02:45:49
【问题描述】:
我正在尝试通过在管理员命令提示符下运行 conda env create -f environment.yml 从 environment.yml 文件创建环境。 environment.yml文件如下:
name: pytorch0.4
channels:
- pytorch
- defaults
dependencies:
- python=3.6.5
- pytorch=0.4.1
- torchvision
- numpy
- nltk
- ipython
- docopt
- pip
- pip:
- tqdm
运行命令后出现这个错误:
Collecting package metadata (repodata.json): done
Solving environment: \
Warning: 2 possible package resolutions (only showing differing packages):
- defaults/noarch::parso-0.8.1-pyhd3eb1b0_0, defaults/win-64::jedi-0.17.0-py36_0
- defaults/noarch::parso-0.7.0-py_0, defaults/win-64::jedi-0.17.2-py36haa95532done
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
Installing pip dependencies: - Ran pip subprocess with arguments:
['C:\\Users\\PC\\anaconda3\\envs\\pytorch0.4\\python.exe', '-m', 'pip', 'install', '-U', '-r', 'C:\\Users\\Assignment\\A2\\a2\\condaenv.1tcu2wl4.requirements.txt']
Pip subprocess output:
Requirement already satisfied: tqdm in c:\users\pc\anaconda3\envs\pytorch0.4\lib\site-packages (from -r C:\Users\Assignment\A2\a2\condaenv.1tcu2wl4.requirements.txt (line 1)) (4.56.0)
Collecting tqdm
Using cached tqdm-4.58.0-py2.py3-none-any.whl (73 kB)
Installing collected packages: tqdm
Attempting uninstall: tqdm
Found existing installation: tqdm 4.56.0
Uninstalling tqdm-4.56.0:
Successfully uninstalled tqdm-4.56.0
Pip subprocess error:
ERROR: Could not install packages due to an OSError: [WinError 5] Access is denied: 'C:\\Users\\PC\\AppData\\Local\\Temp\\pip-uninstall-yeq37y9s\\tqdm.exe'
Consider using the `--user` option or check the permissions.
failed
CondaEnvException: Pip failed
我认为我的环境创建不正确,因为我无法使用环境中的依赖项,也无法激活它。我还尝试通过运行pip install tqdm --user 来安装tqdm,它说Requirement already satisfied: tqdm in c:\users\pc\appdata\roaming\python\python38\site-packages (4.58.0)。那我该如何启动那个环境呢?
【问题讨论】:
-
Conda 在系统级或用户级 Python 安装中表现不佳,尤其是在安装包的
--user时更是如此。如果您想要明确定义的行为,则需要确保 Conda 环境是隔离的(例如,摆脱该用户级 Python)。 -
另外,我不遵循使用
pip安装tdqm的原因。它不仅是available on defaults channel,而且nltk明确依赖于它,所以它肯定已经通过Conda 安装了。整个 ` - pip: ` 部分可以被删除。 -
@merv,你能把它写成答案吗?我会选择它。