gpt4 book ai didi

python - 如何处理 'ImportError: No module named profanity_check'

转载 作者:太空宇宙 更新时间:2023-11-04 11:51:19 25 4
gpt4 key购买 nike

我正在尝试让 profanity_check 在 EC2 Linux 实例上运行。

问题是当我尝试使用 python34 profanity.py.

此外,当尝试运行 python profanity.py 时,我得到一个 ValueError: unsupported pickle protocol: 3 错误。

我认为这是因为 profanity_check 只适用于 Python 3。

此外,当我安装 profanity-check 时,我收到了 DEPRECATION: Python 2.7 will reach the end of its life 警告。但是,我已经在系统上安装了 Python 3.4.9。

根据本期here我已经检查了 __init__.py 文件。它存在并且看起来稳定。

__init__.py 文件的路径如下:

/home/ec2-user/.local/lib/python2.7/site-packages/profanity_check/init.py

这可能是什么问题?

亵渎.py

#!/usr/bin/python34

from profanity_check import predict, predict_prob

predict(['predict() takes an array and returns a 1 for each string if it is offensive, else 0.'])
# [0]

__init__.py

from .profanity_check import predict, predict_prob
__version__="1.0.2"

最佳答案

您已经为 Python 2.7 安装了 profanity_check

/home/ec2-user/.local/lib/python2.7/site-packages/profanity_check/__init__.py

但是你的脚本是使用 Python 3.4 运行的

#!/usr/bin/python34 <-- this here

from profanity_check import predict, predict_prob

更改脚本以使用 python2.7 或为 python3.7 安装 profanity_check

关于python - 如何处理 'ImportError: No module named profanity_check',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56022667/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com