ModuleNotFoundError: No module named 'flask_mysqldb' even if installed - python

I'm using mysql with flask for developing a basic website and I'm getting ModuleNotFound error even if I have the module installed. Can someone solve this ?
File "c:/Users/prshi/Desktop/Py files/FLASK app/app.py", line 3, in <module>
from flask_mysqldb import MySQL
ModuleNotFoundError: No module named 'flask_mysqldb'
PS C:\Users\prshi\Desktop\Py files\FLASK app> pip install flask-mysqldb
Requirement already satisfied: flask-mysqldb in c:\python39\lib\site-packages (0.2.0)
Requirement already satisfied: Flask>=0.10 in c:\python39\lib\site-packages (from flask-mysqldb) (1.1.2)
Requirement already satisfied: mysqlclient in c:\python39\lib\site-packages (from flask-mysqldb) (1.4.6)
Requirement already satisfied: Werkzeug>=0.15 in c:\python39\lib\site-packages (from Flask>=0.10->flask-mysqldb) (1.0.1)
Requirement already satisfied: Jinja2>=2.10.1 in c:\python39\lib\site-packages (from Flask>=0.10->flask-mysqldb) (2.11.2)
Requirement already satisfied: itsdangerous>=0.24 in c:\python39\lib\site-packages (from Flask>=0.10->flask-mysqldb) (1.1.0)
Requirement already satisfied: click>=5.1 in c:\python39\lib\site-packages (from Flask>=0.10->flask-mysqldb) (7.1.2)
Requirement already satisfied: MarkupSafe>=0.23 in c:\python39\lib\site-packages (from Jinja2>=2.10.1->Flask>=0.10->flask-mysqldb) (1.1.1)
PS C:\Users\prshi\Desktop\Py files\FLASK app>

This a common python path issue, to make sure it isn't your case, type :
import sys
print(sys.path)
and check if it contains:
/usr/local/lib64/python3.6/site-packages
The problem is that you install the package using pip somewhere, and you're trying to import it from somewhere else where it's not installed. The trick to solve it is by running this command :
export PYTHONPATH=$PYTHONPATH:/path/to/your/modules

Related

ModuleNotFoundError: No module named 'Crypto' even after installing it

I am trying to run a Jupyter notebook cell that uses firebase module on MacOS Big Sur Python 3.8.2 but it keeps returning this error:
ModuleNotFoundError: No module named 'Crypto'
I ran a pip install Crypto but it said requirement already satisfied
Requirement already satisfied: Crypto in /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages (1.4.1)
Requirement already satisfied: Naked in /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages (from Crypto) (0.1.31)
Requirement already satisfied: shellescape in /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages (from Crypto) (3.8.1)
Requirement already satisfied: pyyaml in /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages (from Naked->Crypto) (5.4.1)
Requirement already satisfied: requests in /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages (from Naked->Crypto) (2.25.1)
Requirement already satisfied: idna<3,>=2.5 in /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages (from requests->Naked->Crypto) (2.10)
Requirement already satisfied: certifi>=2017.4.17 in /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages (from requests->Naked->Crypto) (2020.12.5)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages (from requests->Naked->Crypto) (1.26.3)
Requirement already satisfied: chardet<5,>=3.0.2 in /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages (from requests->Naked->Crypto) (4.0.0)
Note: you may need to restart the kernel to use updated packages.
It still shows the same after I restarted the kernel and even reinstalled the firebase module.

No able to import python modules . Installed pip3 and python 3.5 and python3.7

I want to use requests module on python3.7
But when in run
import requests
it throws error like this
ModuleNotFoundError: No module named 'requests'
However, it works fine with python3.5
When I run pip and pip3 install requests it says
root#helloasc:~# pip install requests
Requirement already satisfied: requests in /usr/local/lib/python3.5/dist-packages (2.23.0)
Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /usr/local/lib/python3.5/dist-packages (from requests) (1.25.8)
Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.5/dist-packages (from requests) (2020.4.5.1)
Requirement already satisfied: chardet<4,>=3.0.2 in /usr/local/lib/python3.5/dist-packages (from requests) (3.0.4)
Requirement already satisfied: idna<3,>=2.5 in /usr/local/lib/python3.5/dist-packages (from requests) (2.9)

Python: why do I get an error when I call geospark?

I get this error when I try to call a geospark module
from geospark.register import GeoSparkRegistrator
ModuleNotFoundError: No module named 'geospark'
However if I do
pip install geospark
I get
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: geospark in /usr/local/lib/python3.6/dist-packages (1.3.0)
Requirement already satisfied: pyspark in /usr/local/lib/python3.6/dist-packages (from geospark) (2.4.5)
Requirement already satisfied: shapely in /usr/local/lib/python3.6/dist-packages (from geospark) (1.7.0)
Requirement already satisfied: findspark in /usr/local/lib/python3.6/dist-packages (from geospark) (1.3.0)
Requirement already satisfied: attrs in /usr/local/lib/python3.6/dist-packages (from geospark) (19.3.0)
Requirement already satisfied: py4j==0.10.7 in /usr/local/lib/python3.6/dist-packages (from pyspark->geospark) (0.10.7)

Python cannot see module after installing via pip

I'm still trying to master the science of installing packages via pip. When I run pip to install geocoder, I get the following:
(base) C:\Users\MBSanders>python -m pip install geocoder
Requirement already satisfied: geocoder in c:\programdata\anaconda3\lib\site-packages (1.38.1)
Requirement already satisfied: requests in c:\programdata\anaconda3\lib\site-packages (from geocoder) (2.21.0)
Requirement already satisfied: future in c:\programdata\anaconda3\lib\site-packages (from geocoder) (0.17.1)
Requirement already satisfied: click in c:\programdata\anaconda3\lib\site-packages (from geocoder) (7.0)
Requirement already satisfied: six in c:\programdata\anaconda3\lib\site-packages (from geocoder) (1.12.0)
Requirement already satisfied: ratelim in c:\programdata\anaconda3\lib\site-packages (from geocoder) (0.1.6)
Requirement already satisfied: certifi>=2017.4.17 in c:\programdata\anaconda3\lib\site-packages (from requests->geocoder) (2019.3.9)
Requirement already satisfied: idna<2.9,>=2.5 in c:\programdata\anaconda3\lib\site-packages (from requests->geocoder) (2.8)
Requirement already satisfied: urllib3<1.25,>=1.21.1 in c:\programdata\anaconda3\lib\site-packages (from requests->geocoder) (1.24.1)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in c:\programdata\anaconda3\lib\site-packages (from requests->geocoder) (3.0.4)
Requirement already satisfied: decorator in c:\programdata\anaconda3\lib\site-packages (from ratelim->geocoder) (4.4.0)
When I run
os.getcwd()
in spyder/python, I get
'C:\\Users\\MBSanders'
My question is, why do I get
ModuleNotFoundError: No module named 'geocoder'
When I run
import geocoder
I'm somewhat new to python. Please let me know if additional info is needed to trouble shoot. I'm within a federal agency so I do not have admin rights.
When I run sys.path in the console, I get
sys.path
Out[12]:
['F:\\Users\\MBSanders',
'C:\\Users\\MBSanders\\AppData\\Local\\Continuum\\anaconda3\\python37.zip',
'C:\\Users\\MBSanders\\AppData\\Local\\Continuum\\anaconda3\\DLLs',
'C:\\Users\\MBSanders\\AppData\\Local\\Continuum\\anaconda3\\lib',
'C:\\Users\\MBSanders\\AppData\\Local\\Continuum\\anaconda3',
'',
'C:\\Users\\MBSanders\\AppData\\Roaming\\Python\\Python37\\site-packages',
'C:\\Users\\MBSanders\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages',
'C:\\Users\\MBSanders\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\win32',
'C:\\Users\\MBSanders\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\win32\\lib',
'C:\\Users\\MBSanders\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\Pythonwin',
'C:\\Users\\MBSanders\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\IPython\\extensions',
'F:\\Users\\MBSanders\\.ipython']
Assuming you're running python on the terminal, and python is the command you're using to run it, try doing python -m pip install geocoder. That'll install it for the python build you want to use. Or if you know the full path to the python build you're using, you can do something similar like /path/to/python -m pip install geocoder.
if you are using python 3.7 or 3.8 you may need to pip3.7 or pip3.8 install if you OS is recognizing a 2.x version as default

ImportError: No module named flask_toastr

I want to use Toastr, for showing non-blocking notifications in my Flask app. I already installed the package with pip :
sudo pip install Flask-Toastr
Here is the output of the installation
Requirement already satisfied: Flask-Toastr in
/Users/****/.local/lib/python3.7/site-packages (0.5.2)
Requirement already satisfied: Flask in
/Users/****/anaconda3/lib/python3.7/site-packages (from Flask-Toastr)
(1.1.1)
Requirement already satisfied: Jinja2 in
/Users/****/anaconda3/lib/python3.7/site-packages (from Flask-Toastr)
(2.10.1)
Requirement already satisfied: click>=5.1 in
/Users/****/anaconda3/lib/python3.7/site-packages (from
Flask->Flask-Toastr) (7.0)
Requirement already satisfied: Werkzeug>=0.15 in
/Users/****/anaconda3/lib/python3.7/site-packages (from
Flask->Flask-Toastr) (0.15.4)
Requirement already satisfied: itsdangerous>=0.24 in
/Users/****/anaconda3/lib/python3.7/site-packages (from
Flask->Flask-Toastr) (1.1.0)
Requirement already satisfied: MarkupSafe>=0.23 in
/Users/****/anaconda3/lib/python3.7/site-packages (from
Jinja2->Flask-Toastr) (1.1.1)
Here is theimport statement:
from flask_toastr import Toastr
But when I run my script I have this ImportError. How can I fix this? Thank you
Without seeing your import statement I suspect you have used a '-' instead of an underscore in the import statement:
Try this:
from flask_toastr import Toastr

Categories

Resources