Install MySQLdb with Anaconda - python

I "successfully" installed MySQLdb using:
pip install mysql-python
But when I use the terminal to check, "import MySQLdb" throws this error:
Traceback (most recent call last):
File "", line 1, in
File "//anaconda/lib/python2.7/site-packages/MySQLdb/init.py", line 19, in
import _mysql
ImportError: dlopen(//anaconda/lib/python2.7/site-packages/_mysql.so, 2): Library not loaded: libssl.1.0.0.dylib
Referenced from: //anaconda/lib/python2.7/site-packages/_mysql.so
Reason: image not found
I'm assuming this is due to some issue with linking, but I don't know what to do.
--- I'm on a Mac. ---

MYsql-python is a wrapper around MySQL client libraries. Here, you seem to lack SSL libraries. Try installing libssl (if you're on a Debian/Ubuntu/Mint)
sudo apt-get install libssl1.0.0

Related

Python : Can't install Pillow library on Pypy3.7 (7.3.1)

Pillow doesn't seem to install on Pypy3.7. I am running this on Mac OS, Catalina 10.15.4.
Pip3 install Pillow
returns:
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/sg/g7xccd2d5ql7cv01qg_3j0440000gn/T/pip-install-6bmk1_j2/pillow/setup.py", line 918, in <module>
raise RequiredDependencyException(msg)
RequiredDependencyException:
The headers or library files could not be found for zlib,
a required dependency when compiling Pillow from source.
Please see the install instructions at:
https://pillow.readthedocs.io/en/latest/installation.html
Is there anything I am missing here? All I see is the missing 'Zlib'. I tried to
brew install Zlib
And reinstalled Xcode just in case. Nothing seems to work. The odd thing is that it works fine with python3 pip, but not with pypy3 pip.
Try to change CPATH:
export CPATH=`xcrun --show-sdk-path`/usr/include

pip3 install mysql-python failed with error code 1 in /tmp/pip-install-4nev4id4/mysql-python/

I am new in python on flask, when i try to install mysql-python by entering the
following command in terminal
pip3 install mysql-python
it shows the following error:
Collecting mysql-python
Using cached https://files.pythonhosted.org/packages/a5/e9/51b544da85a36a68debe7a7091f068d802fc515a3a202652828c73453cad/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 "/tmp/pip-install-4nev4id4/mysql-python/setup.py", line 13, in <module>
from setup_posix import get_config
File "/tmp/pip-install-4nev4id4/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 /tmp/pip-install-4nev4id4/mysql-python/
and then I use this command
sudo apt install default-libmysqlclient-dev in terminal which has been suggested by many i checked on stackoverflow.
and then I retry to install mysql-python but also it is showing the same error, can anyone please help me.
mysql-python only supports Python 2.x, while you seem to be using Python 3. From the linked PyPI page:
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.
To connect to MySQL from Python 3 you can use other alternatives:
mysqlclient
mysql-connector-python
pymysql
cymysql
MySQL-python does not support python3. That is why you get this particular error
ModuleNotFoundError: No module named 'ConfigParser'
In python3 ConfigParser is renamed configparser
One option to connect to MySQL DB is official python connector
Another option is pyodbc
Other options are provided in other answers

importing pycurl with libcurl4 raises ImportError

I am using Ubuntu 18.04. If I install libcurl4 (instead of libcurl3), when I import pycurl installed with pipenv I get
>>> import pycurl
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: /usr/lib/x86_64-linux-gnu/libcurl.so.4: version `CURL_OPENSSL_3' not found (required by /home/pietro/envs/try_fabric-kcbGLH3z/lib/python3.6/site-packages/pycurl.cpython-36m-x86_64-linux-gnu.so)
Note that this error is raised only when I use a pycurl installed with pipenv or pip. If I use instead pycurl installed through apt on system python there are any errors...
What can I do to avoid this impasse?
I assume you upgraded your operating system recently.
pip stores a cache of built wheels in your home directory, when upgrading your os it is a good idea to clear this cache as the binaries may now link against incompatible system libraries
You can do this by rm -rf ~/.cache/pip and then recreate your environment

How to install MySQLdb with Anaconda on Mac

I have the anaconda distribution with python version 2.7. I tried several commands such as sudo and pip but nothing seems to work. I am told in the shell that the installation is complete but every time i try to send in the console "import MySQLdb" i get the following error:
Traceback (most recent call last):
File "", line 1, in
import MySQLdb
File "build/bdist.macosx-10.5-x86_64/egg/MySQLdb/init.py", line 19, in
File "build/bdist.macosx-10.5-x86_64/egg/_mysql.py", line 7, in
File "build/bdist.macosx-10.5-x86_64/egg/_mysql.py", line 6, in bootstrap
ImportError: dlopen(/Users/andreasportelli/.python-eggs/MySQL_python-1.2.5-py2.7-macosx-10.5-x86_64.egg-tmp/_mysql.so, 2): Library not loaded: libssl.1.0.0.dylib
Referenced from: /Users/andreasportelli/.python-eggs/MySQL_python-1.2.5-py2.7-macosx-10.5-x86_64.egg-tmp/_mysql.so
Reason: image not found
What should I do to install it?
Consider using pymysql
You can install it by
conda install pymysql
FYI What is PyMySQL and how does it differ from MySQLdb? Can it affect Django deployment?

Installing PySide on OSX 10.6.8

Trying to get my feet wet with PySide development but having trouble
getting setup. I tried installing the binaries 1.0.4-r1 and 1.0.5 but
both of those produced the following message on import PySide
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Python/2.6/site-packages/PySide/__init__.py", line 2,
in <module>
import private
File "/Library/Python/2.6/site-packages/PySide/private.py", line 2,
in <module>
from QtCore import __moduleShutdown
ImportError: dlopen(/Library/Python/2.6/site-packages/PySide/
QtCore.so, 2): Library not loaded: QtCore.framework/Versions/4/QtCore
Referenced from: /Library/Python/2.6/site-packages/PySide/QtCore.so
Reason: image not found
Then I tried doing the install from the gitorious build scripts. Using
sudo ./dependencies.osx.sh. After that completed I now get the
following error on import PySide.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Python/2.6/site-packages/PySide/__init__.py", line 2,
in <module>
File "/Library/Python/2.6/site-packages/PySide/private.py", line 2,
in <module>
ImportError: No module named QtCore
Any advice is appreciated. I'm using QtCreator 2.2.1 and Qt SDK
1.1.2 / Qt Library 4.7.3. Thank you!
Try to install latest version MacPorts and python 2.7 first and set python2.7 as default python version:
sudo port install python27
port select --list python
sudo port select --set python python27
then re-install PySide again:
sudo port install py27-pyside
I just encountered exactly the same problem:
Library not loaded: QtCore.framework/Versions/4/QtCore
You need to find installed QT libraries and make them visible to the dynamic linker.
My Qt*.framework folders live in /usr/local/lib (Qt is installed with Homebrew package manager). So, I added
export DYLD_FRAMEWORK_PATH=/usr/local/lib:$DYLD_FRAMEWORK_PATH
to ~/.bash_profile and restarted the console.
That's it.
I just solved the same problem by using homebrew to install pyside.
$ sudo -H pip uninstall pyside
$ brew install pyside

Categories

Resources