I have installed pytube by following command
sudo pip install pytube
It's ok when I import pytube from python 2.x.
But I am getting ImportError while importing from python3
Try to install the package with pip3 (sudo pip3 install pytube), in some operating systems pip refers to python2 and pip3 refers to python3.
Try to install pytube3:
sudo pip3 install pytube3
And after that you should be able to import pytube
Related
I installed pytz on Debian Buster via
sudo pip install pytz
and the install completed cleanly. However, when I attempt to
import pytz
python throws an exception
import pytz
ModuleNotFoundError: No module named 'pytz'
I installed pytz 2019.3 via pip 18.1. Any thoughts on why pytz is not found?
Update: I ran pip -v and now see that it is using python2.7. Is there a way to tell pip to use python3? I cannot remove python2 as it is a dependency for a number of packages.
Use pip3 to install modules for python3
Adding to #emrah-diril answer:
sudo apt-get -y install python3-pip
and then use
sudo pip3 install pytz
I'm configuring a bot to send alerts from Zabbix, so I installed Python and the modules:
sudo apt install python python-pip python-setuptools
After that, I installed the bot API to use on Zabbix:
python -m pip install --user pyTelegramBotAPI
Created the script in /usr/lib/zabbix/alertscripts/ :
#!/usr/bin/env python
import telebot,sys
BOT_TOKEN='123TOKENAQUI321'
DESTINATION=sys.argv[1]
SUBJECT=sys.argv[2]
MESSAGE=sys.argv[3]
MESSAGE = MESSAGE.replace('/n','\n')
tb = telebot.TeleBot(BOT_TOKEN)
tb.send_message(DESTINATION,SUBJECT + '\n' + MESSAGE)
Changed permissions:
sudo chmod +x telegram
sudo chown -R zabbix telegram
And when testing the script on terminal or Zabbix the following error appears:
Traceback (most recent call last): File
"/usr/lib/zabbix/alertscripts/telegram", line 2, in
import telebot,sys ImportError: No module named 'telebot'
I tried to solve by installing the module:
python -m pip install --user telebot
Installing the module did not solve it, so I tried to use python3, and the script on the terminal worked, but in Zabbix still showing the same error. I ended up going back to python.
The telebot module does not appear with pip list, only inside the python terminal using the command help ("modules").
Does anyone know that may be causing the problem?
I managed to solve it using python3, but this time I removed the other versions of python completely before installing again, the steps were as follows:
sudo python -m pip uninstall pyTelegramBotAPI
sudo apt remove python python-pip python-setuptools
sudo apt install python3 python3-pip python3-setuptools python3-six
sudo python3 -m pip install pyTelegramBotAPI six
sudo pip install six
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
I installed TFTPy with both pip and pip3.
Then i followed the example on the TFTPy documentation, which follows:
import tftpy
server = tftpy.TftpServer('/tftpboot')
server.listen('0.0.0.0', 69)
But I get the error
ImportError: No module named tftpy
I also tried using from tftpy import tftpy. I tried using Python 2, Python 2.7 and Python 3, but still get the same error.
All help is appreciated
You can install tftpy by using command pip install tftpy. In case you do not have pip on your device, use the following commands:
yum -y install python-pip
pip install --upgrade pip
pip install tftpy
When I try to
import bs4
I keep getting the error
ImportError: No module named bs4
I have tried to address this by trying all of the following (individually and together) with Python 2 and Python 3 and have had no success. What's going wrong?
sudo pip2 install beautifulsoup4
sudo pip3 install beautifulsoup4
sudo apt-get install python-bs4
sudo apt-get install python3-bs4
Downoad it from Pypi beatifulsoup4
and find setup.py file after extracting, then install it with
sudo python setup.py install
I need to import Pubsub_v1 and bigquery from google.cloud module. I have installed it and pip freeze shows below :
gapic-google-cloud-pubsub-v1==0.15.4
google-cloud-bigquery==0.26.0
google-cloud-pubsub==0.27.0
proto-google-cloud-pubsub-v1==0.15.4
In my python script, i am importing the modules as below:
import os
from google.cloud import pubsub_v1
import time
import json
from google.cloud import bigquery
The script is throwing error as :
ImportError: cannot import name pubsub_v1
If i run $sudo pip install --upgrade google-cloud-pubsub then It is able to import pubsub but failing to import Bigquery. I need both modules. Can anybody please help ?
I had the same problem, it happened to me because I installed google-cloud-pubsub before google-cloud so here is my advise :
sudo pip uninstall google-cloud-pubsub
sudo pip uninstall google-cloud
sudo pip install google-cloud
sudo pip install google-cloud-pubsub
Upgraded the other google.cloud modules using
$sudo pip install --upgrade google-cloud-bigquery
$sudo pip install --upgrade google-cloud-storage
$sudo pip install --upgrade google-cloud-logging
It resolves the issue.
$sudo pip install googleapis-common-protos
It resolves the issue for me!
These were helpful to resolve the issue for python 3.x version: (I assumed the pip3 has been installed)
sudo pip3 install google-cloud-bigquery
sudo pip3 install google-cloud-pubsub
sudo apt-get upgrade
I had the same issue while trying the pubsub python library. I followed the below steps to resolve the issue:
Upgrade the pip library:
pip install --upgrade pip setuptools
pip3 install --ignore-installed PyYAML
pip3 install google-cloud-pubsub
just this one solved my issue
the others were not useful
sudo pip3 install google-cloud-pubsub