ModuleNotFoundError while using tqdm after installation in python - python

I'm using a python code using the package tqdm, I installed it with pip
androiddl#androiddl:~$ pip install tqdm Collecting tqdm Using cached
https://files.pythonhosted.org/packages/76/4c/103a4d3415dafc1ddfe6a6624333971756e2d3dd8c6dc0f520152855f040/tqdm-4.30.0-py2.py3-none-any.whl
Installing collected packages: tqdm Successfully installed tqdm-4.30.0
After this success message when I'm trying to run my python script I have this error :
androiddl#androiddl:~/...$
python3 download.py "com.facebook.katana" Traceback (most recent call
last): File "download.py", line 10, in
from playstore.playstore import Playstore File "/home/.../playstore/playstore.py",
line 12, in
from tqdm import tqdm ModuleNotFoundError: No module named 'tqdm'
How can I fix it ? Thank you

It seems like pip is hooked up to Python 2, and not python3, which is what you are using to run your script. Try using pip3 instead. If that doesn't work, a quick way to solve it is to use python3 -m pip install ... for now, although it's nice to have that command located at pip3. Try looking at an answer like How to install pip with Python 3? for that.

Related

How to fix Python import google API error

from googleapiclient.discovery import build
After pip installing google api for python google tells me to use this command however the command doesn't work!
Can anyone help?
https://developers.google.com/docs/api/quickstart/python
Traceback (most recent call last):
File "C:\Users\M1\PycharmProjects\YouTube\main.py", line 1, in <module>
from googleapiclient.discovery import build
ModuleNotFoundError: No module named 'googleapiclient'
https://developers.google.com/docs/api/quickstart/python
I have installed the libraries using the following command:
pip install --upgrade google-api-python-client google-auth-httplib2 google-auth-oauthlib
Then, you can check that the library has been installed properly by running:
pip show google-api-python-client
Now, you should be able to import the libraries in your python code. Make sure that the code is executed within your virtual environment in case you are using one.

no module ipaddress on python2.7.18

I'm using python 2.7.18 on Windows, and i saw that ipaddress library was exclusively for python3 so i installed py2-ipaddress using pip. When i ran pip list into cmd, it shows py2-ipaddress as installed, but when i try import ipaddress into a python file i get this
Traceback (most recent call last):
File "C:/Users/x/Downloads/main (2).py", line 1, in <module>
import ipaddress
ImportError: No module named ipaddress
Why i can't import it?
EDIT :
Actually, ipaddress works fine on python2.7.x, or it should, i installed now ipaddress using pip install ipaddress, it shows as installed when running pip show ipaddress but i still can't import it
#Matthias was right. It seems that my pip doesn't work properly, or i don't know how to use it properly. One quick fix, if you're running pycharm or any IDE with a built-in terminal is to install the module via IDE's terminal using pip install <module>.

importing openbabel wrapper pybel for macos without conda

Previously I asked how to install openbabel for macos here. Now I also need to install the openbabel python wrapper pybel. I tried pip install pybel and it was installed. Then, while I was following the tutorial,
import openbabel
import pybel
mymol = pybel.readstring("smi", "CCCC")
I got the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: module 'pybel' has no attribute 'readstring'
It turns out other people had similar issues and in fact I found in the mailing list that, I quote
'I guess you installed pybel via pip install pybel, which is the
"wrong" pybel'
Then they give a solution which is pip install openbabel, which is not possible for macos.
A solution is to use conda to install openbabel but I am not using conda and I would like to keep it that way so I am looking for a solution which does not require conda.
I found the solution, you can brew install open-babel and then give the path to homebrewed library of python site-packages. For me the following works:
import sys
sys.path.append('/usr/local/lib/python3.8/site-packages')
Then you can
import openbabel
from openbabel import pybel
and so on.
I have exactly the same problem. It works with the following code:
from openbabel import pybel
mymol = pybel.readstring("smi","CCN(CC)CC")
mymol

ModuleNotFoundError: No module named 'camelot'

I want to extract tables from pdf and for that
I used Camelot. But I'm getting this error whenever I try to import it:
import camelot
Traceback (most recent call last):
File "<ipython-input-11-679d8f55abf0>", line 1, in <module>
import camelot
ModuleNotFoundError: No module named 'camelot'
I've tried installing camelot using:
pip install camelot-py[cv]
and
pip install camelot-py[all]
but I'm getting the same error again and again. How do I remove this?
Your help would be appreciated!
Check for your python version by writing python --version in the command prompt with the path where python is installed.
For python 3.7, try:
pip install camelot-py
https://pypi.org/project/camelot-py/
I hope this works for you.
If using conda (this is what I'd recommend):
conda install -c conda-forge camelot-py
If using pip (may have to manually handle dependencies): pip install camelot-py[cv]
Official installation instructions: https://camelot-py.readthedocs.io/en/master/user/install.html#install
Try to install Camelot in correct python version directory using
''''python2.7 -m pip install''''
Use your python version number instead of 2.7 above
In your python environment you have to install padas library.
You can install Camelot python with following command:
pip install Camelot
After the installation of Camelot python library, ModuleNotFoundError: No module named 'Camelot' error will be solved.
Thanks

ImportError: No module named 'prometheus.client'

I am currently trying to run a sample code I code off of the internet.
While trying to run it using python2.7, I get the following ERROR :
# python2.7 example.py
Traceback (most recent call last):
File "example.py", line 9, in <module>
from http.server import HTTPServer
ImportError: No module named http.server
I tried to run the following :
# pip install http.server
Collecting http.server
Could not find a version that satisfies the requirement http.server (from versions: )
No matching distribution found for http.server
But when I use python3, it does not give me the ERROR. Rather gives the ERROR :
# python3 example.py
Traceback (most recent call last):
File "example.py", line 13, in <module>
from prometheus.client import Gauge
ImportError: No module named 'prometheus.client'
Im trying to install prometheus.client using pip and pip3 but nothing.
# pip install prometheus.collectors
Collecting prometheus.collectors
Could not find a version that satisfies the requirement prometheus.collectors (from versions: )
No matching distribution found for prometheus.collectors
# pip3 install prometheus.collectors
Collecting prometheus.collectors
Could not find a version that satisfies the requirement prometheus.collectors (from versions: )
No matching distribution found for prometheus.collectors
How can I get the missing libraries ?
EDIT ::
In the below example I am using a very minimalist approach (again from github)
from prometheus_client import start_http_server, Summary
import random
import time
# Create a metric to track time spent and requests made.
REQUEST_TIME = Summary('request_processing_seconds', 'Time spent processing request')
# Decorate function with metric.
#REQUEST_TIME.time()
def process_request(t):
"""A dummy function that takes some time."""
time.sleep(t)
if __name__ == '__main__':
# Start up the server to expose the metrics.
start_http_server(8000)
# Generate some requests.
while True:
process_request(random.random())
Running the above code yields :
# python3.4 main.yaml
Traceback (most recent call last):
File "main.yaml", line 1, in <module>
from prometheus_client import start_http_server, Summary
ImportError: No module named 'prometheus_client'
Whereas I do have the library installed.
# pip3 install prometheus_client
Requirement already satisfied: prometheus_client in /usr/lib/python2.7/site-packages
I'm running on ubuntu 18.10 and i got the same issue, and i have python2 install already. I was able to solved it by installing python3 and python3-pip like below.
sudo apt install python3
sudo apt install python3-pip
pip3 install prometheus_client
May be helpful to somebody!
http.server is a module in Python 3.
See the note for SimpleHTTPServer in Python 2:
Note The SimpleHTTPServer module has been merged into http.server in Python 3. The 2to3 tool will automatically adapt imports when converting your sources to Python 3.
For prometheus.client, you want pip install prometheus_client. See https://github.com/prometheus/client_python
README.md from the repository you linked states:
Deprecated, use: https://github.com/prometheus/client_python
I faced the exact same problem. I installed pip3 using python3 -m pip install --upgrade pip. After that ran pip3 install prometheus_client. After this, the issue got fixed.
sudo -H pip3 install prometheus_client
just worked for me
Found here
https://github.com/b-harvest/terra_oracle_voter_deprecated/issues/17

Categories

Resources