Flask web development. No module named 'MySQLdb' - python

I'm working with Flask following Miguel Grinberg's book at the moment. i've reached the part where i need to interact with MySQL. i've checked everything and yet when i try to create the actual database with the command:
db.create_all()
i get an error saying "No module named 'MySQLdb'". i've tried installing mySQL-python in my virtual environment and i get another error - "No module named 'ConfigParser'". i tried installing that module with pip, but the same error occurs like i didn't install the ConfigParser module at all. any advice? i'm using python version 3.4. i've read a couple of times that MySQLdb doesn't work with python 3, a statement which contradicts what was written in Miguels book, that Flask is compatible both with python 2 and 3.

solved it. needed to install mysqlclient via pip in the virtual environment. mySQL-python apparently doesn't work with python3

Related

Python module not found despite being installed poetry

I think poetry is somehow not in sync with my python compiler.
Running poetry add bcrypt etc. and then running python app.py I get
ModuleNotFoundError: No module named 'bcrypt'
This persists with some other modules, while seemingly it is working with some.
I set poetry env use to which python output, but it still does not work.
What could be wrong? I'm using linux mint.
Which python version you used while installing module and while running the code, it should be same.
Check if the modules is present under Python{version}/lib.
If not try installing with the same python you are using try again.
If not there may be environment variable issue, set the same python version
in ev

ImportError : No module named json

I am using windows subsystem for linux and I have set a virtual environment in my workspace.
I tried installing apache-airflow in the virtual environment and it got installed. But when I am trying to start the airflow webserver, I am getting the error
ImportError- no module named json
I am not being able to resolve the issue. Please help. I am following the guide Get started developing workflows with Apache Airflow
Your problem is because of version compatibility.
You should try compatible version of werkzeug using like "pip install werkzeug==0.15.4" or try to change version of flask.
Also you can refer some below link for reference.
Apache Airflow : airflow initdb throws ModuleNotFoundError: No module named 'werkzeug.wrappers.json'; 'werkzeug.wrappers' is not a package error
https://forum.astronomer.io/t/importerror-no-module-named-werkzeug-wrappers-json-werkzeug-wrappers-is-not-a-package/280

Python external_dependencies: 'google-cloud-pubsub' not working

Environment details
Google cloud pubsub
window 10
Python version: 3.6.3
google-cloud-pubsub version: 0.39.1
Steps to reproduce
I used google-cloud-pubsub in Odoo module. I tried to explain the issue in step by step.
Added 'google-cloud-pubsub' in external_dependencies in python manifest file:
"external_dependencies": { 'python': ['google-cloud-pubsub'] },
Expected result:
Actually, I don't know why this error occurs. Normally it will be work.
Actual result:
When I published python module to Odoo server its threw below error:
odoo.exceptions.UserError: ('Unable to install module "caliva_wsp" because an
external dependency is not met: No module named google-cloud-pubsub', '')
How to solve this issue? I already stuck at this point around 3 days.
Thanks!
This error message is the expected result if you have not installed the dependency. Odoo module manifest external dependencies only check that the external module is available from Odoo code. It does not install the module.
Install google pubsub pip module on your Odoo server with command pip3 install google-cloud-pubsub before installing your own Odoo module. After that your module should be installable.
You can also automate the installation of dependency by putting it in module requirements.txt file. More information on this can be found at https://www.odoo.com/documentation/user/12.0/odoo_sh/getting_started/first_module.html#use-an-external-python-library.

No module named _sqlite3 for scrapyd

I'm new bie to Python who is stucked in the need of recompilation of Python.
I have server with Centos where I have installed Python3.6 and then scrapyd. Everything installed successfully, however when I try to run scrapyd command, it shows me below error:
After search a while, I got to know that sqlite3 should be installed even before Python3.6, however I have installed sqlite3 now but now found that I need recompile the Python.
So, Above is the situation, now I have a question that, is that the case where I needed to install sqlite3 and recompile the Python? If yes then how I can recompile Python? If no then how can I get rid of this issue and can start the scrapyd?
Help is really appreciable.
I believe, you'll need to re-install the python version as per this as actually the sqlite3 is the extension which should be install before Python gets installed.
Please check this -
How to import sqlite3 in my python3.4 successfully?

Installing MySqlDB on Python 3.6

I am unable to resolve this issue for a day now. when i try to execute my django project, pycharm throws the error "No module named 'MySQLdb'". From reference to similar questions on SO. I did try to install packages through file settings, that raises another error
"Could not find a version that satisfies the requirement MySQLdb (from versions: )
No matching distribution found for MySQLdb"
My project requires python 3.6 and the project doesn't seem to be working without MysqlDB. I did try to install mysqlAlchemy and mysqlconnector but it is of no use. Can some one point out how to resolve this ?
I am on mac and there is no issue if i try to run the project from terminal.
EDIT : I did try to install mysql from the pycharm package manager. But it throws another error No module named 'ConfigParser'
It's a common problem in python3.5.3, you may need to pip install pymysql and add the following code to __init__.py at the same directory as wsgi.py. Wish you good luck!
import pymysql
pymysql.install_as_MySQLdb()

Categories

Resources