Installing MySqlDB on Python 3.6 - python

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()

Related

How to know which pip install command to run when requiments.txt is absent

this fellow pythoneer had issues because his code had
import mysql.connector
and his lib wasn't getting recognized.
I had the same issue, so his question
(ImportError: No module named 'MySQL')
helped me a lot. (it solved the problem) But my question is:
How am I suposed to know that mysql.connector is installed via
pip install mysql-connector
and not a simple pip instal mysql that suposedely would install everything and my python code would find the connector sub-lib inside mysql lib ?
usually when we learn how imports work, we learn that if you have
import library.sublibrary
if you already have library installed, it would work. So why is it an exception ?
What am I missing ?
thanks.

ModuleNotFoundError using pip

I have installed the module alpha_vantage using pip. In CMD writing import alpha_vantage does not show an error message, so I assume it is installed properly.
However, when trying to import alpha_vantage in a python program I get this error: "ModuleNotFoundError: No module named 'requests'". I assume the issue is due to the location of the module.
The project is located here:
C:\Users\M\Documents\Python\Investering.
I tried placing the module here by pip: C:\Users\M\Documents\Python\Investering\modules\alpha_vantage
Note pip did not install the module there I simply copied the module folder and placed them in the project folder.
Is it possible to simply copy and paste module folders in other projects? Or how am I supposed to make python acknowledge the module?
The module was installed here:
C:\Users\M\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\alpha_vantage
I'm quite new to python. I have tried adding to sys.path the folder where the module was installed, but it did not seem to help.
Thanks for any help.
Edit: I tried pip install requests and it produced this:
Requirement already satisfied: requests in c:\users\martin\appdata\local\programs\python\python38-32\lib\site-packages
Someone mentioned running: "pip install foo"
It, however, produces this error message:
ERROR: Could not find a version that satisfies the requirement foo (from versions: none) ERROR: No matching distribution found for foo
I am using PyCharm.
I found my error. I had installed python from the website, but had unknowningly installed the 32 bit version, and a 64 bit version. I uninstalled all my python versions and pycharm. Then I reinstalled everything. Now I could easily make the module work. Thanks for the pointers.

PyCharm throws Error "No module named pymongo"

I'm new to Python and just want to connect to MongoDB.
When trying to install pymongo, cmd tells me that the "requirement is already satisfied".
When trying to import pymongo in Pycharm, however, the ModuleNotFoundError is thrown.
I've reinstalled PyCharm with no change.
Any ideas how to fix this?
Settings => Project: => Project Interpreter
look for packages and install pymongo package
https://www.jetbrains.com/help/pycharm/installing-uninstalling-and-upgrading-packages.html
You may have more than one version of python installed in your device and install library in one of them. Type in cmd "where python" and you can see all versions. If you have some version, you need to configure a desire Python interpreter in pycharm.

Flask web development. No module named 'MySQLdb'

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

MySQLdb import error Enthought Canopy

I'm about to lose my mind over this one, so any help is much appreciated.
I'm working with win8.1, and Enthought Canopy Python 2.7.6 that I'm running from the command line. I initally had difficulties installing MySQLdb, but eventually the MySQL‑python‑1.2.5.win‑amd64‑py2.7.exe installer from http://www.lfd.uci.edu/~gohlke/pythonlibs/#mysql-python worked.
Stupidly a few weeks later there was something that wouldn't work in MySQLdb 1.2.4 so I used pip to roll it back to 1.2.4 and now it's gone - anytime I run programs I get 'import error: No module named MySQLdb'
I've tried pip, easy_install, installing from sources, that installer from above again, with no avail. It's saying that it's installed, it's in CP add/remove programs. When I run pip install MySQL-python:
Requirement already satisfied (use --upgrade to upgrade): MySQL-python in c:\use
rs\laura\appdata\local\enthought\canopy\user\lib\site-packages
Cleaning up...
When I navigate to that directory there are two mysqldb folders named - mysqldb - contains - constants, init, connections, converters, cursors, release, times
and mysql_python-1.2.5-py2.7.egg-info - contains - dependency_links, PKG-INFO, SOURCES, top_level
Thanks in advance for any help,
Laura
EDIT:
I ended up working around the problem by using pymysql instead.
I have MySQLdb module locally installed and can run scripts with it in the command line just fine, but when I run scripts with the MySQLdb module in the Canopy IDE then it does not work. I would check to see if MySQLdb module is an installed package on Canopy because im pretty sure (could be wrong) that you have to subscribe to canopy to get that module. Hope that helps

Categories

Resources