pycharm配置深度学习环境
写在前面:这篇文章记录了深度学习小白第一次配置环境过程中遇到的问题及解决方法,方便以后查阅也欢迎大家交流~
注:最终的解决方案在“更新”部分,不想看我的报错解决艰辛历程的小伙伴可以直接跳转查看,有相同报错的小伙伴也可以试试我尝试过的方法,说不定你的问题能解决~
创建环境(报错套娃)
可以通过下面的指令导出当前环境配置信息,可以生成environment.yml文件
conda env export > environment.yml
environment.yml文件长下面这个样子,记录了运行代码需要的packages和对应版本:
将environment.yml文件放在工作目录下,可以通过以下命令从该文件创建环境
conda env create -f environment.yml
-
报错第一波:
ResolvePackageNotFound
原因: 环境配置文件是在别的机器上导出的,文件里的软件包是按照那个机器配置的,导出的时候,把这些包的详细信息也导了出来。当我们按照这个文件创建环境时,conda会结合我们机器的配置信息,按照配置文件里包的详细信息,去找这个包,结果发现“查无此包”,环境创建失败,报出Solving environment: failed
和ResolvePackageNotFound
解决: 将报错的代码注释掉,添加在pip之后,用pip安装
好了,至此没有ResolvePackageNotFound
这个报错了,但是出现了新的问题! -
报错第二波:
Found conflicts! Looking for incompatible packages.
原因: 报错之后出现一大堆Package XX conflicts for:
,应该是environment.yml中的包与已安装的包版本不匹配
解决: 将package等号后面的版本删除,例如将torch==0.4.1
改为torch
至此,conflicts报错解决(不知道不同版本会不会有影响,先走着看!)我看着包一个一个下载完成的进度条,嘴角逐渐上扬,就在这时,噔噔!新一波报错来了
-
报错第三波:
CondaEnvException: Pip failed
在那么多令人愉悦的100%
之后,出现了这样一行错误,那么的刺眼突兀
解决: 发现了最前面的一个warning,试着更新了一下condaconda update -n base -c defaults conda
一切清零,重新来过
这一次,我卸载重装miniconda,把它添加到环境变量再试一次!尽量把能避免的问题都避免一下
更换清华源
更换为清华源:
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
若要还原,可用下面的命令:
pip config unset global.index-url
再次创建环境
conda env create -f environment.yml
开始了,熟悉的100%,这次能成功吗
倒地,还是一样的又报了好多错误,如下:
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://pypi.tuna.tsinghua.edu.cn/simple
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://pypi.tuna.tsinghua.edu.cn/packages/00/de/98331d2d9aaf7894f58642134f1a8851ce1df063000975400ad1e0a01417/dask-2022.2.1-py3-none-any.whl (1.1 MB)
Collecting torch
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/d4/53/c4a13bbab1385d505c78064ad5ae6a63a990f207a559fcfe950bdeb5f96c/torch-1.10.2-cp38-cp38-win_amd64.whl (226.6 MB)
Collecting zc.buildout
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/6e/9d/73a6609e1dcf92628396aa6f3e75c73bbd0dc46f46f8d74e1c68117eebd6/zc.buildout-2.13.6-py2.py3-none-any.whl (154 kB)
Collecting zc.recipe.egg
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/7a/6f/c6871e8490a153c3b44ac43e4a6552d802561a12b4780c7ea088a7ec5ff0/zc.recipe.egg-2.0.7.tar.gz (39 kB)
Collecting bob.ap
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/32/d1/31546bedbf1e9f6153121b8d31e5084338118b59be59789e2a375e18bf2a/bob.ap-2.1.13.zip (88 kB)
Installing build dependencies: started
Installing build dependencies: still running...
Installing build dependencies: finished with status 'error'
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/03/f3/74044156764d8f460ec18ea2739fd50f4efda21b8d1f095b4542ce9bf54b/bob.ap-2.1.12.zip (88 kB)
Installing build dependencies: started
Installing build dependencies: finished with status 'error'
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/e5/a1/80532db351982fc0fae1a21667cef3b04fc816f87bd39c35eb67eac21a26/bob.ap-2.1.11.zip (88 kB)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/22/e2/068ee8d9f13451f8ca0c34c9c03cecffa6f577a14d6e9b24e65f2b752d9c/bob.ap-2.1.10.zip (88 kB)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/f2/85/0f4a7b44c292fc2d3cc9e6cf643af3964dcf178c2ac005bfe5c7738db488/bob.ap-2.1.9.zip (88 kB)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/a3/d2/f1101244eee8bf2994fbcbfa54ee50fbfc1125658955028df33b4c6f6fb6/bob.ap-2.1.8.zip (88 kB)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/79/fd/843423ea5bd80d1f91a3027739bfc2d0d539543f33dc1693af48b27ebf6b/bob.ap-2.1.7.zip (87 kB)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/d2/9b/ecf55f8af90fc918bbfe148baaa81eec272a80c2523282bfc30a3de668f2/bob.ap-2.1.6.zip (87 kB)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/55/f9/9e8915f69b317c77ee06b8de4fdd0e4083f4fb82bf8ba9e3ac5d91b3fae7/bob.ap-2.1.5.zip (87 kB)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/d9/4c/286c7dd6de7d48e7bc81310a049f14bb086bc672b34d029b0704a905d998/bob.ap-2.1.4.zip (87 kB)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/48/7a/5000632c71674c5167ab4ba5b9f75ed74a65922401a98c9e4894330bee17/bob.ap-2.1.3.zip (90 kB)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/b9/63/07249a3be4ebf703936f88a85978b6b292a3fa13038e6acfd1d8589b3052/bob.ap-2.1.2.zip (90 kB)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/61/d5/012bf283fd3d4abe48bb759c93734df65d503c815959e2a82d3466d58e2d/bob.ap-2.1.1.zip (90 kB)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/07/d1/eaa0807a7f6a5218948b05c02ef6381a0defdb4a185b6a6806f4b3936131/bob.ap-2.1.0.zip (90 kB)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/9d/a5/6b76fe44d5d81463aacf6a90f9617bf36f40c320047cec7db65a5ab0bd3a/bob.ap-2.0.5.zip (81 kB)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/1a/7d/f6edfee6b7ab95dbf9d7a80052f2835e0b1b3b0421be87a9cf0ebf5a5037/bob.ap-2.0.4.zip (81 kB)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/a8/16/69be42995f20da8fe56c71312b8b4ca731a252cc6a2ce4e9ce8ffe767023/bob.ap-2.0.3.zip (81 kB)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/5c/08/f11ac2c5652d75b7e4abf64d5ffd03b9f7e936df4ae47c4ab7081e406778/bob.ap-2.0.2.zip (82 kB)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/a9/ad/593a7853ce068243ba6be7e148019cb940b342acdb6fffbcf8031b731d87/bob.ap-2.0.1.zip (82 kB)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/9e/e2/5e15517528b851b302797415d966969a65645d1a56052448e031894cbb74/bob.ap-2.0.0.zip (81 kB)
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://pypi.tuna.tsinghua.edu.cn/simple -- setuptools wheel bob.extension bob.blitz bob.core bob.sp
cwd: None
Complete output (601 lines):
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting setuptools
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/3b/02/8d4d27b1cacaac2d129a27d17a22d92a2a5eedcb7817d4ed8ab0d4daf5c4/setuptools-60.9.3-py3-none-any.whl (1.1 MB)
Collecting wheel
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/27/d6/003e593296a85fd6ed616ed962795b2f87709c3eee2bca4f6d0fe55c6d00/wheel-0.37.1-py2.py3-none-any.whl (35 kB)
Collecting bob.extension
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/48/14/3cd3e96175264abb60731b4684cc3184f33e6c9481fbf72aefbc3af7e791/bob.extension-6.1.1.zip (106 kB)
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://pypi.tuna.tsinghua.edu.cn/simple -- setuptools wheel bob.extension
cwd: None
Complete output (54 lines):
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting setuptools
Using cached https://pypi.tuna.tsinghua.edu.cn/packages/3b/02/8d4d27b1cacaac2d129a27d17a22d92a2a5eedcb7817d4ed8ab0d4daf5c4/setuptools-60.9.3-py3-none-any.whl (1.1 MB)
Collecting wheel
Using cached https://pypi.tuna.tsinghua.edu.cn/packages/27/d6/003e593296a85fd6ed616ed962795b2f87709c3eee2bca4f6d0fe55c6d00/wheel-0.37.1-py2.py3-none-any.whl (35 kB)
Collecting bob.extension
Using cached https://pypi.tuna.tsinghua.edu.cn/packages/48/14/3cd3e96175264abb60731b4684cc3184f33e6c9481fbf72aefbc3af7e791/bob.extension-6.1.1.zip (106 kB)
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://pypi.tuna.tsinghua.edu.cn/packages/48/14/3cd3e96175264abb60731b4684cc3184f33e6c9481fbf72aefbc3af7e791/bob.extension-6.1.1.zip#sha256=bb50ba9f58478945acc2a9ce34aeb23f0c510850c642b78fc128c8921f11dfc9 (from https://pypi.tuna.tsinghua.edu.cn/simple/bob-extension/) is already being built: bob.extension from https://pypi.tuna.tsinghua.edu.cn/packages/48/14/3cd3e96175264abb60731b4684cc3184f33e6c9481fbf72aefbc3af7e791/bob.extension-6.1.1.zip#sha256=bb50ba9f58478945acc2a9ce34aeb23f0c510850c642b78fc128c8921f11dfc9
还有 ModuleNotFoundError: No module named 'bob.extension'
,如下:
WARNING: Discarding https://pypi.tuna.tsinghua.edu.cn/packages/ee/f1/ce10a9d988e0f98c3a4a318e206bd4058abe1b47e3401be54d2725390c47/bob.blitz-2.0.23.zip#sha256=20a743b0973768a88e110326d89444a6590029aba2f706c0e2235e9c7250929d (from https://pypi.tuna.tsinghua.edu.cn/simple/bob-blitz/). Command errored out with exit status 2: '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-fhmhg8d7\overlay' --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.tuna.tsinghua.edu.cn/simple -- setuptools wheel bob.extension numpy Check the logs for full command output.
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/91/be/db95e3df6134fec458f87577a0cac820b51181e05836d3dcc5a0292b47d9/bob.blitz-2.0.22.zip (122 kB)
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 "<string>", 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://pypi.tuna.tsinghua.edu.cn/packages/9e/e2/5e15517528b851b302797415d966969a65645d1a56052448e031894cbb74/bob.ap-2.0.0.zip#sha256=c039de38206216f1daec643ea8a79c1ef20136b840b6eb0f824e9ff27910a5a8 (from https://pypi.tuna.tsinghua.edu.cn/simple/bob-ap/). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
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直接安装依然报错:
躺平。。。
更新
之前的方法冲突很多没有解决,一直没有更新后续,导致很多小伙伴看完了还是不知道咋弄,抱歉(>人<;)
用下面这个命令建环境报错,那咱就换个方法,不是一定要environment.yml文件才能配环境哦~
conda env create -f environment.yml
后来我换了一个方法 : 自己创建环境,自己下载依赖包
一般开源项目都会有requirements.txt
文件说明环境需要的包,以我的这个项目来说,就是这个:
七个!!看吧,比起这个environment.yml
里面两百多个包,简直是天堂哇
那具体的环境配置操作呢,可以参考这个链接,非常详细,我就不再写啦:
https://blog.csdn.net/weixin_44791964/article/details/106037141
PS:虽然最后我得知这个bob包只支持Linux,在我挣扎未果后,换了一个实现链接,但是配环境的方法就还是一样的,刚开始写博客有很多不足的地方,欢迎大家交流~~
文章出处登录后可见!