Creating an environment from an environment.yml file tqdm access is denied

Question:

I am trying to create an environment from an environment.yml file by running conda env create -f environment.yml in an administrator command prompt. The environment.yml file is as the following:

name: pytorch0.4
channels:
  - pytorch
  - defaults
dependencies:
  - python=3.6.5
  - pytorch=0.4.1
  - torchvision
  - numpy
  - nltk
  - ipython
  - docopt
  - pip
  - pip:
    - tqdm

After running the command, this error appeared:

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:userspcanaconda3envspytorch0.4libsite-packages (from -r C:UsersAssignmentA2a2condaenv.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

I don’t think my environment was created correctly, since I cannot use the dependencies in the environment nor activate it. I also tried to install tqdm by running pip install tqdm --user, it says that Requirement already satisfied: tqdm in c:userspcappdataroamingpythonpython38site-packages (4.58.0). How do I initiate that environment then?

Asked By: Chen

||

Answers:

Conda should be able to solve this without resorting to pip since tdqm is available on the defaults channel. Moreover, nltk has tdqm as dependency, so the YAML could be simplified to

File: pytorch0.4.yaml

name: pytorch0.4
channels:
  - pytorch
  - defaults
dependencies:
  - python=3.6.5
  - pytorch=0.4.1
  - torchvision
  - numpy
  - nltk
  - ipython
  - docopt
  - pip

Also, while using pip in Conda environments is valid, it comes with some caveats. One of these is to never use the --user flag, since this ends up placing packages outside the environment’s site-packages and can lead to violating the isolation of environments that Conda is so keen on establishing.

Answered By: merv

Go to "pyvenv.cfg" file in your Python project and change include-system-site-packages from false to true.

Answered By: S.Panta
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.