python - Python3 错误:pip 安装后没有名为 telebot 的模块
问题描述
python 3.5.2 // Ubuntu 16.04 LTS
我已经安装了 pyTelegramBotAPI 来使用以下命令为电报编码机器人:
pip instal pyTelegramBotAPI
结果:
Collecting pyTelegramBotAPI
Requirement already satisfied: six in /home/username/.local/lib/python2.7/site-packages (from pyTelegramBotAPI) (1.11.0)
Collecting requests (from pyTelegramBotAPI)
Using cached https://files.pythonhosted.org/packages/49/df/50aa1999ab9bde74656c2919d9c0c085fd2b3775fd3eca826012bef76d8c/requests-2.18.4-py2.py3-none-any.whl
Collecting certifi>=2017.4.17 (from requests->pyTelegramBotAPI)
Using cached https://files.pythonhosted.org/packages/7c/e6/92ad559b7192d846975fc916b65f667c7b8c3a32bea7372340bfe9a15fa5/certifi-2018.4.16-py2.py3-none-any.whl
Collecting chardet<3.1.0,>=3.0.2 (from requests->pyTelegramBotAPI)
Using cached https://files.pythonhosted.org/packages/bc/a9/01ffebfb562e4274b6487b4bb1ddec7ca55ec7510b22e4c51f14098443b8/chardet-3.0.4-py2.py3-none-any.whl
Collecting idna<2.7,>=2.5 (from requests->pyTelegramBotAPI)
Using cached https://files.pythonhosted.org/packages/27/cc/6dd9a3869f15c2edfab863b992838277279ce92663d334df9ecf5106f5c6/idna-2.6-py2.py3-none-any.whl
Collecting urllib3<1.23,>=1.21.1 (from requests->pyTelegramBotAPI)
Using cached https://files.pythonhosted.org/packages/63/cb/6965947c13a94236f6d4b8223e21beb4d576dc72e8130bd7880f600839b8/urllib3-1.22-py2.py3-none-any.whl
Installing collected packages: certifi, chardet, idna, urllib3, requests, pyTelegramBotAPI
然后,我将它导入到我的源代码中:
import telebot
但是,当我运行代码时,出现以下错误:
Traceback (most recent call last):
File "firstBot.py", line 1, in <module>
import telebot
ImportError: No module named 'telebot'
解决方案
它主要发生在 Linux 用户身上,因为在 shell 中有一个预安装的 python(版本 2.x),当您安装新模块或使用 default 运行您的应用程序时python
,它会运行并由 .x 提供服务python2.x
。您应该pip3
在安装它时使用它,或通过以下方式运行您的应用程序python3 app_main_file.py
推荐阅读
- python - get() 返回了多个 Product -- 它返回了 14
- python - 由于套接字未在 Python 中连接,因此不允许发送或接收数据的请求
- python - 如何将 str.startswith 与多个字符串一起使用?
- java - 错误:Spring Boot 中使用 Graphql 的唯一索引或主键违规?
- node.js - Apache 反向代理到 NodeJS WebSocket 服务器
- flutter - 每次按下添加按钮时如何显示输入表单?
- android - 当我与 android 应用程序上的 gradle 文件同步时,我面临以下错误.. 任何人都可以解决这个问题
- android - 使用 mapbox 库在 html/appAndroid 中添加 geotiff 文件
- machine-learning - 如何在拟合 Sklearn 估计器和转换器之前手动指定正类
- android - FillMaxHeight、填充和包装内容在 JetpackCompose 中的行为不符合预期