ImportError: No module named flask_toastr - python

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

Related

AttributeError: 'Repo' object has no attribute 'create_pull'

I'm currently running the following python script. The intention is to be able to automatically create a PR.
if new_repo != None: #if there are files within the repo
current = new_repo.create_head(new_branch)
new_repo.git.checkout(current)
new_repo.git.rm('file.yml') #remove the file
print("deleting file")
new_repo.git.commit("-m",'deleting file') #apply a commit message
print("changes are being commited")
new_repo.git.push('--set-upstream', new_repo.remote().name, new_branch) #set an upstream for the branch to remote
print("changes are being pushed")
new_repo.create_pull(title="deleting file", body="just a line to test", head=new_branch, base="master")
The code is working up until I try to create a PR. I end up with the following error:
AttributeError: 'Repo' object has no attribute 'create_pull'
Currently I am using python3 and it's version is Python 3.8.2. I'm unsure about the version on pygithub. I know I have installed it because when I run pip3 install pygithub I get the following output:
Requirement already satisfied: pygithub in /usr/local/lib/python3.9/site-packages (1.55)
Requirement already satisfied: requests>=2.14.0 in /usr/local/lib/python3.9/site-packages (from pygithub) (2.25.1)
Requirement already satisfied: pynacl>=1.4.0 in /usr/local/lib/python3.9/site-packages (from pygithub) (1.4.0)
Requirement already satisfied: deprecated in /usr/local/lib/python3.9/site-packages (from pygithub) (1.2.12)
Requirement already satisfied: pyjwt>=2.0 in /usr/local/lib/python3.9/site-packages (from pygithub) (2.1.0)
Requirement already satisfied: cffi>=1.4.1 in /usr/local/lib/python3.9/site-packages (from pynacl>=1.4.0->pygithub) (1.14.4)
Requirement already satisfied: six in /usr/local/lib/python3.9/site-packages (from pynacl>=1.4.0->pygithub) (1.15.0)
Requirement already satisfied: pycparser in /usr/local/lib/python3.9/site-packages (from cffi>=1.4.1->pynacl>=1.4.0->pygithub) (2.20)
Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.9/site-packages (from requests>=2.14.0->pygithub) (2021.5.30)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in /usr/local/lib/python3.9/site-packages (from requests>=2.14.0->pygithub) (1.26.6)
Requirement already satisfied: chardet<5,>=3.0.2 in /usr/local/lib/python3.9/site-packages (from requests>=2.14.0->pygithub) (4.0.0)
Requirement already satisfied: idna<3,>=2.5 in /usr/local/lib/python3.9/site-packages (from requests>=2.14.0->pygithub) (2.10)
Requirement already satisfied: wrapt<2,>=1.10 in ./Library/Python/3.9/lib/python/site-packages (from deprecated->pygithub) (1.12.1)
Is there something that I am missing with my troubleshooting? Is the code incorrect? As far as I know, I've been looking at the following SO postand this PyGithub post.
Could someone help me out? If someone could provide an explanation as well that'll be amazing.
Thanks!

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.

ModuleNotFoundError: No module named 'flask_mysqldb' even if installed

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

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

Categories

Resources