简体   繁体   English

导入电报时出错

[英]Error while importing telepot

I'm trying to build my own bot but I've some troubles when I try to import the telepot package. 我正在尝试构建自己的机器人,但是在尝试导入telepot软件包时遇到了一些麻烦。 I installed telepot with the command to a virtualenv : 我使用命令将telepot安装到virtualenv

pip install telepot

and I've no problems when I do 而且我做的时候没有问题

python
import telepot

But to use the GPIO it's necessary the be the super user, so 但是要使用GPIO ,必须成为超级用户,因此

sudo python
import telepot

but the answer is 但是答案是

ImportError: No module named telepot

What is wrong? 怎么了?

Since you are using virtualenv and want to execute Python with sudo , try this: 由于您正在使用virtualenv并想使用sudo执行Python,请尝试以下操作:

  1. activate your virtualenv 激活您的虚拟环境
  2. pip install telepot
  3. get the path to virtualenv's Python with which python 获取使用which python virtualenv的Python路径
  4. deactivate virtualenv 停用virtualenv
  5. execute sudo <path_to_python_from_step3> 执行sudo <path_to_python_from_step3>
  6. import telepot should work now import telepot应立即工作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM