记一次靠发懵/直觉/试错解决bug的经历,总之不是完全靠思考···,很有趣
刚刚装完显卡,vs, cuda, cudnn, pytorch gpu版本一串软件····
结果打开以前的程序,发现matplotlib,joblib等等基础的外部包没了,毕竟换了解释器,这是题中应有之义,
但是安装不了,一安装就直接报错!!!这就有毛病了
(问题已经解决了,随便找了个包academic复现之前的错误类型,重点是错误)
把执行命令复制下来在终端执行,看更详细的报错信息:
(base) C:\Users\Administrator\PycharmProjects\EmotionRecog>conda activate pytorch_gpu
(pytorch_gpu) C:\Users\Administrator\PycharmProjects\EmotionRecog>D:\ProgramData\Anaconda3\Scripts\conda.exe install -p D:/ProgramData/Anaconda3/envs/pytorch_gpu academic -y
# >>>>>>>>>>>>>>>>>>>>>> ERROR REPORT <<<<<<<<<<<<<<<<<<<<<<
Traceback (most recent call last):
File "D:\ProgramData\Anaconda3\lib\site-packages\conda\exceptions.py", line 1074, in __call__
return func(*args, **kwargs)
File "D:\ProgramData\Anaconda3\lib\site-packages\conda\cli\main.py", line 84, in _main
exit_code = do_call(args, p)
File "D:\ProgramData\Anaconda3\lib\site-packages\conda\cli\conda_argparse.py", line 82, in do_call
exit_code = getattr(module, func_name)(args, parser)
File "D:\ProgramData\Anaconda3\lib\site-packages\conda\cli\main_install.py", line 20, in execute
install(args, parser, 'install')
File "D:\ProgramData\Anaconda3\lib\site-packages\conda\cli\install.py", line 116, in install
if context.use_only_tar_bz2:
File "D:\ProgramData\Anaconda3\lib\site-packages\conda\base\context.py", line 666, in use_only_tar_bz2
import conda_package_handling.api
File "D:\ProgramData\Anaconda3\lib\site-packages\conda_package_handling\api.py", line 3, in <module>
from libarchive.exception import ArchiveError as _LibarchiveArchiveError
File "D:\ProgramData\Anaconda3\lib\site-packages\libarchive\__init__.py", line 1, in <module>
from .entry import ArchiveEntry
File "D:\ProgramData\Anaconda3\lib\site-packages\libarchive\entry.py", line 6, in <module>
from . import ffi
File "D:\ProgramData\Anaconda3\lib\site-packages\libarchive\ffi.py", line 48, in <module>
libarchive = ctypes.cdll.LoadLibrary(libarchive_path)
File "D:\ProgramData\Anaconda3\lib\ctypes\__init__.py", line 434, in LoadLibrary
return self._dlltype(name)
File "D:\ProgramData\Anaconda3\lib\ctypes\__init__.py", line 356, in __init__
self._handle = _dlopen(self._name, mode)
TypeError: LoadLibrary() argument 1 must be str, not None
An unexpected error has occurred. Conda has prepared the above report.
Upload successful.
这个问题简直一点思路都没有,让我十分痛苦,看到网上很多人出现同样的问题,但是别人都只有一个base 解释器,和我的情况不太一样,我装cuda版本的pytorch过程中创建了新的解释器pytorch_gpu,这个pytorch_gpu只是个名字,任意起的哈
大家说的比较可信的一个说法:dll文件的问题,无法动态链接到库,但我还是不知道怎么解决,只是觉得这是对这个错误的正确解释
怎么都没解决,僵持了很久,叹了不少的气,出了不少头皮油之后,看着屏幕上的安装package的界面,觉得conda的绿色圈圈挺好看的,鬼使神差地想着点点它在安装试试,结果···guess what? 这个绿圈圈就是终极答案!!!超级像密室逃脱解密游戏有没有······随便乱试的或者靠着女人神奇的intuition, the sixth sense, whatever,就这么通关了啊哈哈哈哈,棘手bug通关后的喜悦之情溢于言表
点击绿圈圈使用conda包管理器之后,瞬间安装成功
后面在pycharm的终端安装了一下上面用来举例的academic包,结果很正常的就装好了,仔细一看,原来是因为终端默认使用base解释器,所以不需要conda包管理器,就可以正常安装外部库
(base) C:\Users\Administrator\PycharmProjects\EmotionRecog>D:\ProgramData\Anaconda3\Scripts\conda.exe install -p D:/ProgramData/Anaconda3/envs/pytorch_gpu academic -y
Collecting package metadata (current_repodata.json): done
Solving environment: done
## Package Plan ##
environment location: D:\ProgramData\Anaconda3\envs\pytorch_gpu
added / updated specs:
- academic
The following packages will be downloaded:
package | build
---------------------------|-----------------
academic-0.5.1 | py_0 12 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
bibtexparser-1.1.0 | py_0 32 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
chardet-3.0.4 | py37_1003 184 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
cryptography-2.8 | py37hb32ad35_0 567 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
idna-2.8 | py37_1000 100 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
pyparsing-2.4.5 | py_0 58 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
pysocks-1.7.1 | py37_0 27 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
requests-2.22.0 | py37_1 84 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
toml-0.10.0 | py_0 16 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
urllib3-1.25.7 | py37_0 159 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
------------------------------------------------------------
Total: 1.2 MB
The following NEW packages will be INSTALLED:
academic anaconda/cloud/conda-forge/noarch::academic-0.5.1-py_0
bibtexparser anaconda/cloud/conda-forge/noarch::bibtexparser-1.1.0-py_0
chardet anaconda/cloud/conda-forge/win-64::chardet-3.0.4-py37_1003
cryptography anaconda/cloud/conda-forge/win-64::cryptography-2.8-py37hb32ad35_0
future anaconda/cloud/conda-forge/win-64::future-0.18.2-py37_0
idna anaconda/cloud/conda-forge/win-64::idna-2.8-py37_1000
pyopenssl anaconda/cloud/conda-forge/win-64::pyopenssl-19.0.0-py37_0
pyparsing anaconda/cloud/conda-forge/noarch::pyparsing-2.4.5-py_0
pysocks anaconda/cloud/conda-forge/win-64::pysocks-1.7.1-py37_0
requests anaconda/cloud/conda-forge/win-64::requests-2.22.0-py37_1
toml anaconda/cloud/conda-forge/noarch::toml-0.10.0-py_0
urllib3 anaconda/cloud/conda-forge/win-64::urllib3-1.25.7-py37_0
win_inet_pton anaconda/cloud/conda-forge/win-64::win_inet_pton-1.1.0-py37_0
Downloading and Extracting Packages
pyparsing-2.4.5 | 58 KB | ################################################################################################################################################ | 100%
toml-0.10.0 | 16 KB | ################################################################################################################################################ | 100%
pysocks-1.7.1 | 27 KB | ################################################################################################################################################ | 100%
chardet-3.0.4 | 184 KB | ################################################################################################################################################ | 100%
bibtexparser-1.1.0 | 32 KB | ################################################################################################################################################ | 100%
cryptography-2.8 | 567 KB | ################################################################################################################################################ | 100%
academic-0.5.1 | 12 KB | ################################################################################################################################################ | 100%
requests-2.22.0 | 84 KB | ################################################################################################################################################ | 100%
idna-2.8 | 100 KB | ################################################################################################################################################ | 100%
urllib3-1.25.7 | 159 KB | ################################################################################################################################################ | 100%
Preparing transaction: done
Verifying transaction: done
done
而激活pytorch_gpu解释器之后,再这么装,就要报文首提的错,这是因为pytorch_gpu解释器需要conda包管理器才可以正常安装外部库
(base) C:\Users\Administrator\PycharmProjects\EmotionRecog>conda activate pytorch_gpu
(pytorch_gpu) C:\Users\Administrator\PycharmProjects\EmotionRecog>D:\ProgramData\Anaconda3\Scripts\conda.exe install -p D:/ProgramData/Anaconda3/envs/pytorch_gpu academic -y
# >>>>>>>>>>>>>>>>>>>>>> ERROR REPORT <<<<<<<<<<<<<<<<<<<<<<
重要结论说三遍: