我正在尝试通过在管理员命令提示符下运行 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
我认为我的环境创建不正确,因为我无法使用环境中的依赖项也无法激活它。我还尝试通过运行 tqdm
来安装 pip install tqdm --user
,它说 Requirement already satisfied: tqdm in c:\users\pc\appdata\roaming\python\python38\site-packages (4.58.0)
。那么我如何启动该环境?
答案 0 :(得分:1)
Conda 应该能够在不求助于 pip
的情况下解决这个问题,因为 tdqm
在 defaults 频道上可用。此外,nltk
具有 tdqm
作为依赖项,因此 YAML 可以简化为
文件:pytorch0.4.yaml
name: pytorch0.4
channels:
- pytorch
- defaults
dependencies:
- python=3.6.5
- pytorch=0.4.1
- torchvision
- numpy
- nltk
- ipython
- docopt
- pip
此外,虽然在 Conda 环境中使用 pip
是有效的,但 it comes with some caveats。其中之一是永远不要使用 --user
标志,因为这最终会将包放置在环境的 site-packages
之外,并可能导致违反 Conda 非常热衷于建立的环境隔离。