Hi
I have been following a step by step on how to make a login system with python, with flask-mysqldb. I'm trying to run the python script, but i end up getting a error message that i don't understand so much of.
from flask import Flask, render_template, request, redirect, url_for, session
from flask_mysqldb import MySQL
import MySQLdb.cursors
import re
app = flask(__name__)
When I'm trying to run the script, on the localhost page it also shows a error, I have copyed and pasted te error in pastebin. When I try to install the flask_mysqldb i get a error in my cmd. Here is what my cmd says.
I have google with parts of the error, trying to find some information about what the problem can be. And tryed to pip install a lot for things that some people have said that can work, without any luck. And can't figure out how to get this to work.
I also tryed to install Anaconda terminal to run the command in there for installing flask_mysqldb, but no luck. Tryed to uninstall and reinstall everything, but nothing changed the error i get.
The error:
ModuleNotFoundError: No module named 'flask_mysqldb'
indicates that the module has not been installed or installed in a wrong environment.
Install it using:
pip install flask-mysqldb
The stack from from the error
File "c:\users\chris\appdata\local\programs\python\python37-32\lib\site-packages\flask\cli.py", line 240, in locate_app
__import__(module_name)
File "C:\xampp\htdocs\pythonlogin\main.py", line 2, in <module>
from flask_mysqldb import MySQL
ModuleNotFoundError: No module named 'flask_mysqldb'
is indicating that Python 3.7 in involved.
In this case, using pip to install flask_mysqldb will lead to grief. Use pip3 instead. E.g.,
pip3 install flask_mysqldb
Related
I am trying to follow this guide: https://www.imaginarycloud.com/blog/flask-python/ in order to generate documentation for my flask app. After I installed the werkzeug, I started getting the following error:
Traceback (most recent call last):
File "/home/jnordling/.local/bin/flask", line 5, in <module>
from flask.cli import main
File "/home/jnordling/.local/lib/python3.6/site-packages/flask/__init__.py", line 7, in <module>
from .app import Flask as Flask
File "/home/jnordling/.local/lib/python3.6/site-packages/flask/app.py", line 19, in <module>
from werkzeug.local import ContextVar
ImportError: cannot import name 'ContextVar'
Steps to reproduce:
Install flask: pip install flask
Create a Basic flask app
Install flask-restplus: pip install flask-restplus
Install Werkzeug: pip install Werkzeug
Create Documentation Endpoint:
Run App
Based on a quick glance through the tutorial, it looks like it might be a package version compatibility issue.
Have you tried upgrading Flask and Werkzeug to the latest versions?
Maybe try:
pip install Flask Werkzeug -U
It's version incompatibility that's causing the issue. A clean uninstall followed by a fresh install should fix the issue.
pip uninstall Flask Werkzeug
pip install Flask Werkzeug
When I install package with python and import it, I often get a missing imports message such as:
Import "fastapi" could not be resolvedPylancereportMissingImports
The imports always work perfectly fine, the fastapi example above will run a server and I can build an API without issue.
Can anyone explain why I am getting this error and how I could get rid of it?
Reinstall fastapi again separately.
pip install 'fastapi[all]'
pip install fastapi
pip install uvicorn
Hello I am running an application with Flask and have installed flask-cors as per the documentation, however when I try to import the module into my app.py file I get this error:
from flask_cors import CORS
ModuleNotFoundError: No module named 'flask_cors'
Anyone know what may be going wrong here?
Try to run in console following command:
pip install flask_cors
or in some case
pip3 install flask_cors
And be sure that you running Python 3 instead of Python 2
I am running django version 1.10.3 and I installed google api client with pip like so:
pip install --upgrade google-api-python-client
When I try to use it with PyCharm/Terminal outside of a django project it works just fine. However, when I try to import it in my django project it throws this error:
ImportError: No module named googleapiclient
For this import statement:
from googleapiclient import discovery
I don't use any virtual env and nothing. Does anybody know why this error occurs?
Thanks in advance!
I'm trying to connect to connect to my MongoDB instance from my FLASK app and I've run into an issue. I followed the tutorial at https://flask-pymongo.readthedocs.org/en/latest/
When I try to run the server I get the following error:
ImportError: No module named flask.ext.pymongo
I've ran pip install Flask-PyMongo.
The code fails when I try to import PyMongo using from flask.ext.pymongo import PyMongo
Turns out the solution to the problem was that I needed to download Flask-PyMongo to my projects local libs folder using pip install -t lib Flask-PyMongo
This is due to the line in my config file vendor.add('lib')