(1)报错:ModuleNotFoundError: No module named 'faiss.swigfaiss_avx2
# 进入python环境的faiss目录
cd your_python_path/site-packages/faiss
# 在git bash中打开
ln -s swigfaiss.py swigfaiss_avx2.py
(2)报错:line 6, in from streamlit.cli import main ModuleNotFoundError: No module named 'streamlit.cli
解决办法是,找到安装环境中的streamlit文件,打开,找到第6行,将 from streamlit.cli import main,改为from streamlit.web.cli import main 即可
# 在终端输入
streamlit hello
在结果中呈现下面内容,那么就成功了
👋 Welcome to Streamlit!
If you’d like to receive helpful onboarding emails, news, offers, promotions,
and the occasional swag, please enter your email address below. Otherwise,
leave this field blank.
(3)asyncio使用异常:This event loop is already running解决方式
asyncio是Python 3.4版本引入的标准库,直接内置了对异步IO的支持。最近我在多线程调用使用asyncio方法的时候,出现报错:This event loop is already running
asyncio不允许嵌套事件出现,需要引入nest_asyncio。
# 安装相关库
pip install nest_asyncio -i https://pypi.douban.com/simple
# 添加相关代码
import nest_asyncio
nest_asyncio.apply()
(4)ModuleNotFoundError: No module named ‘exceptions‘
解决方案如下:
pip uninstall docx
pip install python-docx
(5)ImportError: cannot import name COMMON_SAFE_ASCII_CHARACTERS‘ from charset-normalizerconstant‘
# 尝试以下命令更新模块
pip install --upgrade charset-normalizer
# 如果仍然无法解决问题,请尝试卸载charset_normalizer模块,然后重新安装
pip uninstall charset-normalizer
pip install charset-normalizer
(6)ValueError: Unknown encoding cl100k_base
相关链接:https://github.com/openai/tiktoken/issues/80
# Add the following to your pyinstaller prompt to make it executable:
--hidden-import=tiktoken_ext.openai_public --hidden-import=tiktoken_ext
(7)安装MMCV
官网安装说明:https://mmcv.readthedocs.io/zh-cn/latest/get_started/installation.html#pip
(8)windows Pyhton中安装jq的问题
国外大神自编译的 jq windows python 安装库,下载链接如下:
https://jeffreyknockel.com/jq/
(9)提示错误:ModuleNotFoundError: No module named ‘numpy.typing‘
pip install -U numpy
(10) AttributeError: 'Row' object has no attribute 'style' #693
pip install gradio==3.41.2
(11) AttributeError: module 'numpy' has no attribute 'float'.
`np.float` was a deprecated alias for the builtin `float`.
To avoid this error in existing code, use `float` by itself.
Doing this will not modify any behavior and is safe.
If you specifically wanted the numpy scalar type, use `np.float64` here.
pip install numpy==1.23.5
(12) 解决Anacoda新建环境或者升级conda update anaconda-navigator 报错问题
报错:cannot update anaconda navigator JSONDecodeError
试过的方法
(1)删除磁盘的.condarc
(2)pip install requests --upgrade
(3)conda clean --all
(4)conda update --all -y
(13)ImportError: cannot import name 'ValidationInfo' from 'pydantic'
https://github.com/deepinsight/insightface/issues/2563
pip uninstall pydantic
pip install --upgrade numpy
pip install pyre-extensions==0.0.29
pip install albumentations==1.4.3
pip install pydantic==1.10.13
pip uninstall albumentations pydantic
pip install albumentations pydantic==1.10.9
(14) Importing onnx fails with "DLL load failed while importing onnx_cpp2py_export" #6267
https://github.com/onnx/onnx/issues/6267
# 版本更换
pip install onnx==1.16.1
(15)subprocess.CalledProcessError: Command ‘[‘where‘, ‘cl‘]‘ returned non-zero exit status 1
(1)下载vs2017或者VS2019,不要下VS2022,这里我安装在D盘
(2)添加环境变量 D:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\bin\Hostx64\x64
(3)重启电脑
(16)AttributeError: module 'numpy' has no attribute 'float'.
`np.float` was a deprecated alias for the builtin `float`. To avoid this error in existing code, use `float` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.float64` here.
The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations. Did you mean: 'cfloat'?
方案一: pip install numpy==1.23.5
方案二: np.float 替换为 float 或者 np.float_ , 如果报下面的错误,然后进一步解决
numpy报错:The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (5,) + inhomogeneous part.
解决方案1: pipi install numpy==1.23.5
方案2: trans_params = np.array([w0, h0, s, np.asscalar(t[0]), np.asscalar(t[1])]) 替换为以下
trans_params = np.array([w0, h0, s])
trans_params = np.append(trans_params, t[0])
trans_params = np.append(trans_params, t[1])
(17)ModuleNotFoundError: No module named 'triton'
下载windows下的安装包,进行安装
# Python 3.10
https://huggingface.co/madbuda/triton-windows-builds/resolve/main/triton-2.1.0-cp310-cp310-win_amd64.whl
# Python 3.11
https://huggingface.co/madbuda/triton-windows-builds/resolve/main/triton-2.1.0-cp311-cp311-win_amd64.whl
(18)NotImplementedError: cuda not supported. Supported strategies are: balanced
pip install diffusers==0.27.2
(19)I tensorflow/core/util/port.cc:153] oneDNN custom operations are on.
You may see slightly different numerical results due to floating-point round-off errors from different computation orders.
To turn them off, set the environment variable `TF_ENABLE_ONEDNN_OPTS=0`.
# 在主程序的最前添加下面的代码行
import os
# (0代表显示所有信息,1表示不显示info,2表示不显示warning,3表示不显示error)
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
(20)ModuleNotFoundError: No module named 'pillow_avif'
pip install pillow-avif-plugin
(21)解决opencv中使用cv2.imshow不显示图片问题
pip uninstall opencv-python
pip uninstall opencv-contrib-python
pip install opencv-contrib-python
(22)报错:ModuleNotFoundError: No module named‘torchvision.transforms.functional_tensor‘
a) import torchvision.transforms._functional_tensor as F_t
b) pip install torch==2.2.0 torchvision==0.17.0 torchaudio==2.2.0 --index-url https://download.pytorch.org/whl/cu121
(23)raise AttributeError(attribute) AttributeError: __pydantic_core_schema__
pip install fastapi==0.112.0