'Telebot' has no attribute 'types' - python

Well, I've tried to run another's person telegram bot on my computer, but got a mistake that:
Traceback (most recent call last):
File "C:\Users\Dmitriy\PycharmProjects\pythonProject\Main.py", line 10, in <module>
keyboard = telebot.types.ReplyKeyboardMarkup(True, True)
AttributeError: module 'telebot' has no attribute 'types'
I've tried to import types from telebot:
from telebot import types
But it didn't actually helped. The strangest thing is that this code works on code owner's computer.
What can this be about?
enter image description here

The problem is that telebot and pyTelegramBotApi are different libraries but they are both imported via import telebot. In fact, when you do from telebot import types you import it from pyTelegramBotApi, not from telebot.
To fix the issue just type:
pip uninstall telebot
pip uninstall pyTelegramBotApi
pip install pyTelegramBotApi
It worked for me :)

You need to install python-telegram-bot f.e via pip
pip install python-telegram-bot
then import it from telegram package
from telegram import ReplyKeyboardMarkup
and replace creation of ReplyKeyboardMarkup into this:
keyboard = ReplyKeyboardMarkup(True, True)

for like these errors ... reinstall the library or use (--upgrade) when you install it !
like this:
pip uninstall telebot
pip install pyTelegramBotAPI
pip install pytelegrambotapi --upgrade
Happy Coding!

If you use PyCharm, then I advise you to do the following.
Go to the directory of your project.
In this directory, open the venv\Scripts directory (eventually you should get the following path \venv\Scripts)
Next, go to the command line along this path AND ONLY AFTER THAT WRITE the pip install pyTelegramBotAPI COMMAND ♥

Related

Module Not found error: office365 not found

I have seen this issue with some resolutions already, but none have worked for my issue. I have pip installed the latest version of office365(v 2.2.0) to my knowledge using the command:
pip install office365-rest-client
I am trying to import using the following lines of code:
from office365.runtime.auth.authentication_context import AuthenticationContext
from office365.sharepoint.client_context import ClientContext
from office365.sharepoint.files.file import File
I receive the following error:
ModuleNotFoundError: No module named 'office365'
Just to test it out, I uninstalled and reinstalled pandas, then successfully imported pandas into my project.
Install this
pip install Office365-REST-Python-Client
pip install office365
After that, restart your IDE and errase and write again the imports. I no have idea why this worked for me
ATTENTION - You must make the letter O lowercase in both install commands, as below. Capital O does not work.
pip install office365-REST-Python-Client
pip install office365
You also need to install the office365 library as well as office365-rest-client
pip install office365

No module called 'discord' found

I'm trying to make a discord bot. So I did 'pip install discord' and it installed successfully! I have added Python to PATH as well. now in the Python Shell, I typed, 'import discord'. Then I get this error:
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import discord
ModuleNotFoundError: No module named 'discord'
I have used 'pip install discord' again and again and it still doesn't work! My pip is also the latest version. I also uninstalled and installed python but still doesn't work! :(
Why does it not work? Please help me. Thanks!!
I think this is because it is
pip install discord.py and not
pip install discord.
If you are on Linux, try pip3 install discord.py (pip installs to python2 by default).
You can also see the official pypi project.
This should be a simple solution. A previous answer indicated to make sure that you use the correct, full module name when making the pip call to install the module, and this is imperative -- however, since you're still not seeing results there is clearly still an issue.
The first question is what is your python download? Did you install python through something like conda, or did you just install the language directly on your device without a facilitating package?
In the meantime (and especially if you don't know the answer to the above question), try this command in your terminal (not your python shell, just your command line):
pip freeze
This command is referenced from this link, in case you're curious, and should give you a list of all locally install non-default python packages. If you provide the result of this call, I am certain it will better facilitate the solving of this issue.
Me to, I got this error.
I solved it as follows:
import discord.abc
if you use linux and run the pip install command as non root but the start command as root you need to run the pip command also as root

Telebot import issue

When I'm trying to import telebot it gives me the error.
Error:
I've tried to reinstall telegramBotApi several times but it didn't work out.
Telebot associated with pyTelegramBotAPI not telegramBotApi.
Run this : pip install pyTelegramBotAPI

ImportError: cannot import name 'InsecureRequestWarning' (PYTHON3 | RPI3 | gTTS)

I'm having trouble using gTTS (Google Text to Speech) on my raspberry Pi 3. I simply did
sudo pip3 install gTTS
to install it. But when I run my code I find this error :
File "interface.py", line 7, in <module>
from gtts import *
File "/usr/local/lib/python3.4/dist-packages/gtts/\__init__.py", line 2, in <module>
from .tts import gTTS
File "/usr/local/lib/python3.4/dist-packages/gtts/tts.py", line 4, in <module>
from requests.packages.urllib3.exceptions import InsecureRequestWarning
ImportError: cannot import name 'InsecureRequestWarning'
To try to solve the problem I did
sudo easy_install --upgrade pip
Then I have uninstalled and installed again gtts but the problem persists.
Thank you very much for your help ! :(
PS : I have installed python-vlc and mutagen to make working gTTS (as I did on a windows device)
Just update requests library
pip install -U requests
Try this way.`
import urllib3`
urllib3.disable_warnings()
Though it doesn't remove the entire warning message, still removes the Insecure Request Warning
Fixed it by running pip install requests==2.6.0
if you face issue with bringing request library to 2.6.0 first remove pyopenssl and then run pip install requests==2.6.0
I don't know if you still want to know but I can partially answer it.
import gtts
why this will work is because gtts automatically imports .tts and gTTS.
This is gtts.__init():
from .version import __version__
from .tts import gTTS
It's the only code in there.
You can go look yourself in the folder:
/usr/local/lib/python3.4/dist-packages/gtts
OR
/usr/local/lib/python2.7/dist-packages/gtts
I am also trying to figure out still, how to use it but otherwise no.

How to install google.cloud with Python pip?

I am relatively new to Python and I am stuck on something which is probably relatively easy to resolve.
I have installed the following packages:
pip install --upgrade google-api-python-client
pip install --upgrade google-cloud
pip install --upgrade google-cloud-vision
In my Python file I have:
import cv2
import io
import os
# Imports the Google Cloud client library
from google.cloud import vision
...etc...
And this gives me the error:
Traceback (most recent call last):
File "test.py", line 6, in <module>
from google.cloud import vision
ImportError: No module named 'google.cloud'
What am I missing and where should I look (logs?) to find the answer in the future.
PS:
Pip installs of google-cloud and google-cloud-vision have the output:
Cannot remove entries from nonexistent file /Users/foobar/anaconda/lib/python3.5/site-packages/easy-install.pth
UPDATE:
Running pip freeze doesn't show the packages to be installed...
I had a similar problem. Adding "--ignore-installed" to my pip command made it work for me.
This might be a bug in pip - see this page for more details: https://github.com/pypa/pip/issues/2751
You need to download and install the google-cloud-sdk. Follow this link https://cloud.google.com/sdk/docs/
try this :
from google.cloud.vision import *

Categories