Eastsheng's Wiki

Python问题与解决方法汇总

2021-01-22 18:11:28

[toc]

报错信息:subprocess-exited-with-error

  • pip install 时报错信息:

    1
    error: subprocess-exited-with-error × Getting requirements to build wheel did not run successfully. │ exit code: 1 ╰─> [22 lines of output]
  • 解决方法:

    1
    pip install --upgrade pip setuptools wheel

Windows下"MINGW64"中运行python没反应

  • (1). 可以pip list,也可以python --version,但是直接输入python就卡那不动了

  • (2). 解决方法–>在 MINGW64 git shell 中输入以下命令即可解决:
1
alias python='winpty python.exe'

  • (3). 但是,发现这只是临时的,关了再重新打开输入python,还是没反应
  • (4). 永久解决方法,将第2步命令直接复制到以下文件中:C:\Users\yourcomputer\.bash_profile

参考链接:
[1] https://www.codenong.com/32597209/

FileNotFoundError: Could not find module

  • (1).引用vlc库时报错:
1
2
FileNotFoundError: Could not find module '...\2021\2021-3\libvlc.dll' (or one of its dependencies). 
Try using the full path with constructor syntax.
  • (2).解决方法:

①. 首先pip list查看vlc的版本:

②. 然后,下载并解压对应vlc版本 http://download.videolan.org/pub/videolan/vlc/

③. 将文件夹中pluginslibvlc.dlllibvlccore.dll,复制到添加到已经设置环境变量的文件夹中,这里我直接复制到D:\softwares\Python\Python39\Scripts

参考链接:
[1] https://stackoverflow.com/questions/59014318/filenotfounderror-could-not-find-module-libvlc-dll
[2] https://blog.csdn.net/fleaxin/article/details/101943941
④. 解决

Centos 7安装python3

StopIteration

  • StopIteration异常,一般是由于迭代时所给的数据超出实际数据范围所致;
  • 如果想要正常运行已给出数据范围的程序,则可以处理异常程序:
    1
    2
    3
    4
    5
    6
    re = iter(range(5))
    try:
    for i inrange(200):
    print("normal: ",re.next())
    except StopIteration:
    print('Here is stop ',i)

overflow encountered

1
RuntimeWarning: overflow encountered in det r = _umath_linalg.det(a, signature=signature)
  • 计算行列式时溢出;
  • 没解决。

unindent does not match any outer indentation level

  • 如果缩进没有问题的画,这个主要是错误主要就是TAB和空格混用了。
  • 使用notepad++打开视图>显示符号>显示空格与制表符查看缩进。
  • 修改成一种就可以了。

安装conda报错

1
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
1
2
3
4
conda -V
conda update -n base conda
conda update --all

  • 还不行就换conda镜像
1
2
3
4
5
6
7
channels:
- https://mirrors.ustc.edu.cn/anaconda/pkgs/main/
- https://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
- defaults
show_channel_urls: true