pycharm配置深度学习环境:conda env create -f environment.yml报错

pycharm配置深度学习环境

写在前面:这篇文章记录了深度学习小白第一次配置环境过程中遇到的问题及解决方法,方便以后查阅也欢迎大家交流~

注:最终的解决方案在”更新”部分,不想看我的报错解决艰辛历程的小伙伴可以 直接跳转查看,有相同报错的小伙伴也可以试试我尝试过的方法,说不定你的问题能解决~

文章目录

创建环境(报错套娃)

可以通过下面的指令导出当前环境配置信息,可以生成environment.yml文件

conda env export > environment.yml

environment.yml文件长下面这个样子,记录了运行代码需要的packages和对应版本:

pycharm配置深度学习环境:conda env create -f environment.yml报错
将environment.yml文件放在工作目录下,可以通过以下命令从该文件创建环境
conda env create -f environment.yml
  • 报错第一波: ResolvePackageNotFound
    pycharm配置深度学习环境:conda env create -f environment.yml报错
    原因: 环境配置文件是在别的机器上导出的,文件里的软件包是按照那个机器配置的,导出的时候,把这些包的详细信息也导了出来。当我们按照这个文件创建环境时,conda会结合我们机器的配置信息,按照配置文件里包的详细信息,去找这个包,结果发现”查无此包”,环境创建失败,报出 Solving environment: failedResolvePackageNotFound
    解决: 将报错的代码注释掉,添加在pip之后,用pip安装
    pycharm配置深度学习环境:conda env create -f environment.yml报错
    好了,至此没有 ResolvePackageNotFound这个报错了,但是出现了新的问题!
  • 报错第二波: Found conflicts! Looking for incompatible packages.
    pycharm配置深度学习环境:conda env create -f environment.yml报错
    原因: 报错之后出现一大堆 Package XX conflicts for:,应该是environment.yml中的包与已安装的包版本不匹配
    解决: 将package等号后面的版本删除,例如将 torch==0.4.1改为 torch 至此,conflicts报错解决(不知道不同版本会不会有影响,先走着看!)我看着包一个一个下载完成的进度条,嘴角逐渐上扬,就在这时,噔噔!新一波报错来了
    pycharm配置深度学习环境:conda env create -f environment.yml报错
  • 报错第三波: CondaEnvException: Pip failed
    在那么多令人愉悦的 100%之后,出现了这样一行错误,那么的刺眼突兀
    pycharm配置深度学习环境:conda env create -f environment.yml报错
    解决: 发现了最前面的一个warning,试着更新了一下conda conda update -n base -c defaults conda
    pycharm配置深度学习环境:conda env create -f environment.yml报错
    再往上看看,发现还是版本问题:(我删漏了两个包的版本号,重来!)
    pycharm配置深度学习环境:conda env create -f environment.yml报错
    一切都在掌控之中…新的错误出现了👇错误复错误,错误何其多,不知道套娃何时了,继续看下去吧~
    pycharm配置深度学习环境:conda env create -f environment.yml报错
    再次尝试解决: 这个告诉我之前配置的环境文件已经存在,于是删除之前的配置文件 rm -r xxx/xxx重新运行命令 conda env create -f environment.yml
    结果: 还是pip failed,并且报错更多了。。。

一切清零,重新来过

这一次,我卸载重装miniconda,把它添加到环境变量再试一次!尽量把能避免的问题都避免一下

pycharm配置深度学习环境:conda env create -f environment.yml报错

; 更换清华源

更换为清华源:

pip config set global.index-url https:

若要还原,可用下面的命令:

pip config unset global.index-url

再次创建环境

conda env create -f environment.yml

开始了,熟悉的100%,这次能成功吗

pycharm配置深度学习环境:conda env create -f environment.yml报错
倒地,还是一样的又报了好多错误,如下:
  • Installing build dependencies: finished with status 'error'
  • Pip subprocess error: ERROR: Command errored out with exit status 1:
  • ERROR: Exception: Traceback (most recent call last):
  • raise LookupError(message) LookupError:

详细报错信息如下:

| Ran pip subprocess with arguments:
['D:\\DOWNLODES\\miniconda\\envs\\bob.paper.deep_pix_bis_pad.icb2019\\python.exe', '-m', 'pip', 'install', '-U', '-r', 'D:\\code\\bob.paper.deep_pix_bis_pad.icb2019-master\\condaenv.u62n68x0.requirements.txt']
Pip subprocess output:
Looking in indexes: https:
Requirement already satisfied: dask in d:\downlodes\miniconda\envs\bob.paper.deep_pix_bis_pad.icb2019\lib\site-packages (from -r D:\code\bob.paper.deep_pix_bis_pad.icb2019-master\condaenv.u62n68x0.requirements.txt (line 1)) (2021.10.0)
Collecting dask
  Downloading https:
Collecting torch
  Downloading https:
Collecting zc.buildout
  Downloading https:
Collecting zc.recipe.egg
  Downloading https:
Collecting bob.ap
  Downloading https:
  Installing build dependencies: started
  Installing build dependencies: still running...

  Installing build dependencies: finished with status 'error'
  Downloading https:
  Installing build dependencies: started
  Installing build dependencies: finished with status 'error'
  Downloading https:
  Downloading https:
  Downloading https:
  Downloading https:
  Downloading https:
  Downloading https:
  Downloading https:
  Downloading https:
  Downloading https:
  Downloading https:
  Downloading https:
  Downloading https:
  Downloading https:
  Downloading https:
  Downloading https:
  Downloading https:
  Downloading https:
  Downloading https:

Pip subprocess error:
  ERROR: Command errored out with exit status 1:
   command: 'D:\DOWNLODES\miniconda\envs\bob.paper.deep_pix_bis_pad.icb2019\python.exe' 'C:\Users\14129\AppData\Local\Temp\pip-standalone-pip-gg2opnp3\__env_pip__.zip\pip' install --ignore-installed --no-user --prefix 'C:\Users\14129\AppData\Local\Temp\pip-build-env-y1_5pksa\overlay' --no-warn-script-location --no-binary :none: --only-binary :none: -i https:
       cwd: None
  Complete output (601 lines):
  Looking in indexes: https:
  Collecting setuptools
    Downloading https:
  Collecting wheel
    Downloading https:
  Collecting bob.extension
    Downloading https:
    Installing build dependencies: started
    Installing build dependencies: finished with status 'error'
    ERROR: Command errored out with exit status 2:
     command: 'D:\DOWNLODES\miniconda\envs\bob.paper.deep_pix_bis_pad.icb2019\python.exe' 'C:\Users\14129\AppData\Local\Temp\pip-standalone-pip-gg2opnp3\__env_pip__.zip\pip' install --ignore-installed --no-user --prefix 'C:\Users\14129\AppData\Local\Temp\pip-build-env-hj6utavq\overlay' --no-warn-script-location --no-binary :none: --only-binary :none: -i https:
         cwd: None
    Complete output (54 lines):
    Looking in indexes: https:
    Collecting setuptools
      Using cached https:
    Collecting wheel
      Using cached https:
    Collecting bob.extension
      Using cached https:
    ERROR: Exception:
    Traceback (most recent call last):
      File "C:\Users\14129\AppData\Local\Temp\pip-standalone-pip-gg2opnp3\__env_pip__.zip\pip\_internal\cli\base_command.py", line 173, in _main
        status = self.run(options, args)
      File "C:\Users\14129\AppData\Local\Temp\pip-standalone-pip-gg2opnp3\__env_pip__.zip\pip\_internal\cli\req_command.py", line 203, in wrapper
        return func(self, options, args)
      File "C:\Users\14129\AppData\Local\Temp\pip-standalone-pip-gg2opnp3\__env_pip__.zip\pip\_internal\commands\install.py", line 315, in run
        requirement_set = resolver.resolve(
      File "C:\Users\14129\AppData\Local\Temp\pip-standalone-pip-gg2opnp3\__env_pip__.zip\pip\_internal\resolution\resolvelib\resolver.py", line 94, in resolve
        result = self._result = resolver.resolve(
      File "C:\Users\14129\AppData\Local\Temp\pip-standalone-pip-gg2opnp3\__env_pip__.zip\pip\_vendor\resolvelib\resolvers.py", line 472, in resolve
        state = resolution.resolve(requirements, max_rounds=max_rounds)
      File "C:\Users\14129\AppData\Local\Temp\pip-standalone-pip-gg2opnp3\__env_pip__.zip\pip\_vendor\resolvelib\resolvers.py", line 341, in resolve
        self._add_to_criteria(self.state.criteria, r, parent=None)
      File "C:\Users\14129\AppData\Local\Temp\pip-standalone-pip-gg2opnp3\__env_pip__.zip\pip\_vendor\resolvelib\resolvers.py", line 172, in _add_to_criteria
        if not criterion.candidates:
      File "C:\Users\14129\AppData\Local\Temp\pip-standalone-pip-gg2opnp3\__env_pip__.zip\pip\_vendor\resolvelib\structs.py", line 151, in __bool__
        return bool(self._sequence)
      File "C:\Users\14129\AppData\Local\Temp\pip-standalone-pip-gg2opnp3\__env_pip__.zip\pip\_internal\resolution\resolvelib\found_candidates.py", line 140, in __bool__
        return any(self)
      File "C:\Users\14129\AppData\Local\Temp\pip-standalone-pip-gg2opnp3\__env_pip__.zip\pip\_internal\resolution\resolvelib\found_candidates.py", line 128, in <genexpr>
        return (c for c in iterator if id(c) not in self._incompatible_ids)
      File "C:\Users\14129\AppData\Local\Temp\pip-standalone-pip-gg2opnp3\__env_pip__.zip\pip\_internal\resolution\resolvelib\found_candidates.py", line 32, in _iter_built
        candidate = func()
      File "C:\Users\14129\AppData\Local\Temp\pip-standalone-pip-gg2opnp3\__env_pip__.zip\pip\_internal\resolution\resolvelib\factory.py", line 204, in _make_candidate_from_link
        self._link_candidate_cache[link] = LinkCandidate(
      File "C:\Users\14129\AppData\Local\Temp\pip-standalone-pip-gg2opnp3\__env_pip__.zip\pip\_internal\resolution\resolvelib\candidates.py", line 295, in __init__
        super().__init__(
      File "C:\Users\14129\AppData\Local\Temp\pip-standalone-pip-gg2opnp3\__env_pip__.zip\pip\_internal\resolution\resolvelib\candidates.py", line 156, in __init__
        self.dist = self._prepare()
      File "C:\Users\14129\AppData\Local\Temp\pip-standalone-pip-gg2opnp3\__env_pip__.zip\pip\_internal\resolution\resolvelib\candidates.py", line 227, in _prepare
        dist = self._prepare_distribution()
      File "C:\Users\14129\AppData\Local\Temp\pip-standalone-pip-gg2opnp3\__env_pip__.zip\pip\_internal\resolution\resolvelib\candidates.py", line 305, in _prepare_distribution
        return self._factory.preparer.prepare_linked_requirement(
      File "C:\Users\14129\AppData\Local\Temp\pip-standalone-pip-gg2opnp3\__env_pip__.zip\pip\_internal\operations\prepare.py", line 508, in prepare_linked_requirement
        return self._prepare_linked_requirement(req, parallel_builds)
      File "C:\Users\14129\AppData\Local\Temp\pip-standalone-pip-gg2opnp3\__env_pip__.zip\pip\_internal\operations\prepare.py", line 570, in _prepare_linked_requirement
        dist = _get_prepared_distribution(
      File "C:\Users\14129\AppData\Local\Temp\pip-standalone-pip-gg2opnp3\__env_pip__.zip\pip\_internal\operations\prepare.py", line 59, in _get_prepared_distribution
        with req_tracker.track(req):
      File "D:\DOWNLODES\miniconda\envs\bob.paper.deep_pix_bis_pad.icb2019\lib\contextlib.py", line 113, in __enter__
        return next(self.gen)
      File "C:\Users\14129\AppData\Local\Temp\pip-standalone-pip-gg2opnp3\__env_pip__.zip\pip\_internal\req\req_tracker.py", line 128, in track
        self.add(req)
      File "C:\Users\14129\AppData\Local\Temp\pip-standalone-pip-gg2opnp3\__env_pip__.zip\pip\_internal\req\req_tracker.py", line 97, in add
        raise LookupError(message)
    LookupError: https:

还有 ModuleNotFoundError: No module named 'bob.extension',如下:

WARNING: Discarding https:
    Downloading https:
      ERROR: Command errored out with exit status 1:
       command: 'D:\DOWNLODES\miniconda\envs\bob.paper.deep_pix_bis_pad.icb2019\python.exe' -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\14129\\AppData\\Local\\Temp\\pip-install-0xyqgrl9\\bob-blitz_478264b858e04e349d0543544c381481\\setup.py'"'"'; __file__='"'"'C:\\Users\\14129\\AppData\\Local\\Temp\\pip-install-0xyqgrl9\\bob-blitz_478264b858e04e349d0543544c381481\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\14129\AppData\Local\Temp\pip-pip-egg-info-gt8o_es8'
           cwd: C:\Users\14129\AppData\Local\Temp\pip-install-0xyqgrl9\bob-blitz_478264b858e04e349d0543544c381481\
      Complete output (5 lines):
      Traceback (most recent call last):
        File "", line 1, in <module>
        File "C:\Users\14129\AppData\Local\Temp\pip-install-0xyqgrl9\bob-blitz_478264b858e04e349d0543544c381481\setup.py", line 9, in <module>
          from bob.extension import Extension, build_ext
      ModuleNotFoundError: No module named 'bob.extension'

最后报错: CondaEnvException: Pip failed,如下:

WARNING: Discarding https:
ERROR: Could not find a version that satisfies the requirement bob.ap (from versions: 2.0.0b1, 2.0.0, 2.0.1, 2.0.2, 2.0.3, 2.0.4, 2.0.5, 2.1.0, 2.1.1, 2.1.2, 2.1.3, 2.1.4, 2.1.5, 2.1.6, 2.1.7, 2.1.8, 2.1.9, 2.1.10, 2.1.11, 2.1.12, 2.1.13)
ERROR: No matching distribution found for bob.ap

failed

CondaEnvException: Pip failed

接着进入环境,用pip直接安装依然报错:

pycharm配置深度学习环境:conda env create -f environment.yml报错
躺平。。。

更新

之前的方法冲突很多没有解决,一直没有更新后续,导致很多小伙伴看完了还是不知道咋弄,抱歉(>人<;)

用下面这个命令建环境报错,那咱就换个方法,不是一定要environment.yml文件才能配环境哦~

conda env create -f environment.yml

后来我换了一个方法 : 自己创建环境,自己下载依赖包
一般开源项目都会有 requirements.txt文件说明环境需要的包,以我的这个项目来说,就是这个:

pycharm配置深度学习环境:conda env create -f environment.yml报错
七个!!看吧,比起这个 environment.yml里面两百多个包,简直是天堂哇

那具体的环境配置操作呢,可以参考这个链接,非常详细,我就不再写啦:
https://blog.csdn.net/weixin_44791964/article/details/106037141

PS:虽然最后我得知这个bob包只支持Linux,在我挣扎未果后,换了一个实现链接,但是配环境的方法就还是一样的,刚开始写博客有很多不足的地方,欢迎大家交流~~

Original: https://blog.csdn.net/weixin_44177781/article/details/123292667
Author: _hungry
Title: pycharm配置深度学习环境:conda env create -f environment.yml报错

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/625026/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球