Python 运行遇到的问题及解决(后续不断更新...)

(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

  • 18
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值