3
$\begingroup$

I got a very strange error when run conda env create -f environment.yml. Due to proprietary information, I cannot share the content of environemnt.yml, except that it contains a pip section

  - pip
  - pip:
      - sqlalchemy
      - pyyaml

It seems to run OK up to the creation of the requirements.txt file, and then throw the following error

Collecting package metadata: done
Solving environment: done
Preparing transaction: done
Verifying transaction: done
Executing transaction: done

# >>>>>>>>>>>>>>>>>>>>>> ERROR REPORT <<<<<<<<<<<<<<<<<<<<<<

    Traceback (most recent call last):
      File "C:\Users\***\AppData\Local\Continuum\anaconda3\lib\site-packages\conda_env\installers\pip.py", line 42, in _pip_install_via_requirements
        requirements.write('\n'.join(specs))
    TypeError: sequence item 11: expected str instance, list found

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "C:\Users\***\AppData\Local\Continuum\anaconda3\lib\site-packages\conda\exceptions.py", line 1003, in __call__
        return func(*args, **kwargs)
      File "C:\Users\***\AppData\Local\Continuum\anaconda3\lib\site-packages\conda_env\cli\main.py", line 73, in do_call
        exit_code = getattr(module, func_name)(args, parser)
      File "C:\Users\***\AppData\Local\Continuum\anaconda3\lib\site-packages\conda_env\cli\main_create.py", line 101, in execute
        installer.install(prefix, pkg_specs, args, env)
      File "C:\Users\***\AppData\Local\Continuum\anaconda3\lib\site-packages\conda_env\installers\pip.py", line 52, in _pip_install_via_requirements
        os.remove(requirements.name)
    PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'C:\\**current\\work\\dir**\\condaenv.7syuvz37.requirements.txt'

At the end, it asks me to send the report to (conda) core maintainer. Before answering it, I checked the requirements.txt file, it was generated (0 bytes, not read only, owned by me) by this process (based on creation time). I cannot delete it before answering the y/N question. Then I typed N to deny sending the report. Afterwards, I can delete the file. (This seems to suggest that it is NOT locked by others).

I also killed all Python processes using Windows task manager, and rebooted Windows, and ran this command as the first thing (in Anaconda Prompt), with no luck.

Thanks for any suggestions or insights.

$\endgroup$

1 Answer 1

1
$\begingroup$

Just in case someone else has a similar problem and stumbles over this thread like I did:

It's not the PermissionError I needed to fix, it's the TypeError listed above. Which most likely is just a typo / formatting error in the pip section of your environment.yml file, resulting in problems when trying to turn that into a requirements file.

$\endgroup$
1
  • $\begingroup$ Good catch. The exact error: TypeError: sequence item 11: expected str instance, list found $\endgroup$
    – lpounng
    Commented May 19, 2022 at 10:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.