I am trying to connect a MySQL database to my Django project, but when I try to install MySQL-python, it gives me the following error:
Collecting mysql-python
Using cached MySQL-python-1.2.5.zip
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/fr/3k1nrq490dzdz9s48k49m9640000gn/T/pip-build-4dsuxwwv/mysql-python/setup.py", line 13, in <module>
from setup_posix import get_config
File "/private/var/folders/fr/3k1nrq490dzdz9s48k49m9640000gn/T/pip-build-4dsuxwwv/mysql-python/setup_posix.py", line 2, in <module>
from ConfigParser import SafeConfigParser
ModuleNotFoundError: No module named 'ConfigParser'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/fr/3k1nrq490dzdz9s48k49m9640000gn/T/pip-build-4dsuxwwv/mysql-python/
I have tried pip3 install ConfigParser, but while it gets installed, the error still occurs.
When I try to run my Django server, it prints out a long error log, and at the end:
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module.
Did you install mysqlclient?
and when I looked at the following link, it said that I should install MySQL-python: Django mysqlclient install
May seem like a newbie question, but I can't seem to find similar errors elsewhere online.
EDIT:: Ok, looks like MySQL-python is not for python-3.6
While I did pip3 install mysqlclient, the virtualenv is saying that I have already installed it when I run the command again. But when I try to python3 manage.py runserver, I get the above error, asking if I had installed it. When I try to give an answer, I am unable to. Everytime I press ENTER, it just creates a new line and the prompt is still active.
The above error is preceded by the following text:
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x1059d9048>
Traceback (most recent call last):
File "/Users/karthikpullela/Desktop/Django-projects/QB-test/QB/lib/python3.6/site-packages/django/db/backends/mysql/base.py", line 15, in <module>
import MySQLdb as Database
File "/Users/karthikpullela/Desktop/Django-projects/QB-test/QB/lib/python3.6/site-packages/MySQLdb/__init__.py", line 19, in <module>
import _mysql
ImportError: dlopen(/Users/karthikpullela/Desktop/Django-projects/QB-test/QB/lib/python3.6/site-packages/_mysql.cpython-36m-darwin.so, 2): Library not loaded: libmysqlclient.18.dylib
Referenced from: /Users/karthikpullela/Desktop/Django-projects/QB-test/QB/lib/python3.6/site-packages/_mysql.cpython-36m-darwin.so
Reason: image not found
The above exception was the direct cause of the following exception:
Python 3 does not include ConfigParser
only has configparser
>>> import ConfigParser
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'ConfigParser'
>>> import configparser
Try Python 2.7 which still works if we use import ConfigParser
Try to install with different package, it has support for python 3.
pip install mysqlclient
If there is error while installing in virtualenv, do install this first.
sudo apt-get -y install python3-dev libmysqlclient-dev
Related
I'm running a python program in Terminal using Python 3.8.2.
After running it on a new device, installing requirements (pip3 install requirements.txt), and trying to run (python3 swift-runner.py), I got an error saying "No module named yolk"
I hadn't ever gotten that on my original device and was still able to run the program on my original device. So I ran pip3 install yolk and then got a new error No module named 'xmlrpclib'
I tried recreating the issue on my original device by running pip3 install yolk and now I get the same error No module named 'xmlrpclib'
Was installing yolk the right approach, where now I just need to install the new module? Or am I going the wrong direction?
Console Messages:
Fadis-MacBook-Pro:~ fadisaleh$ python3 /Users/fadisaleh/Downloads/Optimus\ Most\ Updated\ February\ 2020/swift-runner.py
Traceback (most recent call last):
File "/Users/fadisaleh/Downloads/Optimus Most Updated February 2020/swift-runner.py", line 5, in <module>
from swift.swift import main
File "/Users/fadisaleh/Downloads/Optimus Most Updated February 2020/swift/swift.py", line 28, in <module>
from yolk import yolklib, pypi
File "/Users/fadisaleh/Library/Python/3.8/lib/python/site-packages/yolk/pypi.py", line 20, in <module>
import xmlrpclib
ModuleNotFoundError: No module named 'xmlrpclib'
[UPDATE] - An antivirus software installed on my computer was causing the issue. Disabling it solved the problem :)
I'm getting a weird error when I try to import psycopg2.
Using Python 3.7.7
Downloaded psycopg2 using pip
$ python -m pip install psycopg2
Collecting psycopg2
Using cached psycopg2-2.8.5-cp37-cp37m-win_amd64.whl (1.1 MB)
Installing collected packages: psycopg2
Successfully installed psycopg2-2.8.5
import psycopg2
if name =="main":
print("Hello World!")
Running the code gives me the below error:
$ python test2.py Traceback (most recent call last): File "test2.py", line 1, in <module>
import psycopg2
File "C:\Users\blah\AppData\Local\Programs\Python\Python37\lib\site-packages\psycopg2\__init__.py", line 51, in <module>
from psycopg2._psycopg import ( # noqa ImportError: dynamic module does not define module export function (PyInit__psycopg)
Have tried installing pscopg2-binary instead. Still getting the same error.
Any idea?
A similar report was posted, but the suggested solutions do not work.
---- from Jupyter ----
Import psycopg2
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-2-7d2da0a5d979> in <module>
----> 1 import psycopg2
ModuleNotFoundError: No module named 'psycopg2'
If I run python3 from Mac terminal and then import psycopg2 that works.
If I run python3 from Jupyterlab terminal this does not work. I get the following error after running import pyscopg2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/psycopg2/__init__.py", line 50, in <module>
from psycopg2._psycopg import ( # noqa
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/psycopg2/_psycopg.cpython-38-darwin.so, 2): Library not loaded: #rpath/libssl.1.1.dylib
Referenced from: /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/psycopg2/_psycopg.cpython-38-darwin.so
Reason: image not found
echo $PATH from Mac terminal is
/Users/greg/opt/miniconda3/bin:/Users/greg/opt/anaconda3/condabin:/Library/Frameworks/Python.framework/Versions/3.8/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
echo $PATH from Jupyterlab terminal is
/Library/Frameworks/Python.framework/Versions/3.8/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/greg/opt/miniconda3/bin:/Users/greg/opt/anaconda3/condabin
These look the same, just in a different order.
I have tried pip install psycopg2 both with and without the binary option.Either way, it says already satisfied.
I have tried
conda install -c anaconda psycopg2
Also tried installing postgresql both from the postgresql.org, and brew install psycopg2. Both worked, but no luck with Jupyterlab.
try installing the package using: pip install psycopg2-binary. This should work.
For more information, visit: https://www.psycopg.org/docs/install.html
I'm integrating MySQL as backend with my Django application. At the time of installation i'm running following command (using mac os)
export PATH=$PATH:/usr/local/mysql/bin
start server from settings (i'm on mac os)
brew install mysql-connector-c
sudo pip install MySQL-python
while running last command i'm getting following error,
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/tmp/pip-build-wd69ia4g/MySQL-python/setup.py", line 13, in <module>
from setup_posix import get_config
File "/private/tmp/pip-build-wd69ia4g/MySQL-python/setup_posix.py", line 2, in <module>
from ConfigParser import SafeConfigParser
ImportError: No module named 'ConfigParser'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/tmp/pip-build-wd69ia4g/MySQL-python/
I google the error and got the solutions as run following command
export PATH=$PATH:/usr/local/mysql/bin
But it doesn't solve my error.
Can any body help me to get out of it or let me know the steps for the initial MySQL setup.
Can not getting the solution than i'm ready for the fresh installation. Post the exact steps here
I'm building a web application that needs to use a mySql database. I created a database in mysql workbench. When i try to run the command for django :
'python manager.py runserver'
i get the following error:
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named 'MySQLdb'
When i try to install MySQLdb (for python 3.4.3) via 'pip install mysql-python' i get following error :
Collecting mysql-python
Using cached MySQL-python-1.2.5.zip
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 20, in <module>
File "/private/var/folders/cg/_w0sc5ms4hj3k5rcrf2mfm500000gn/T/pip-build-5qbm_4en/mysql-python/setup.py", line 13, in <module>
from setup_posix import get_config
File "/private/var/folders/cg/_w0sc5ms4hj3k5rcrf2mfm500000gn/T/pip-build-5qbm_4en/mysql-python/setup_posix.py", line 2, in <module>
from ConfigParser import SafeConfigParser
ImportError: No module named 'ConfigParser'
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/cg/_w0sc5ms4hj3k5rcrf2mfm500000gn/T/pip-build-5qbm_4en/mysql-python
Read about MySQL-python on PyPI:
MySQL-3.23 through 5.5 and Python-2.4 through 2.7 are currently supported. Python-3.0 will be supported in a future release. PyPy is supported.
If you want to stick to Python 3.x you'll need to use mysqlclient