Install MySQLdb on a Mac - python

I have Python 32 bits, I installed MySQL Community server 32 bits and I'm trying to install MySQLdb for Python.
I run
easy_install mysql-python
and I have this error
> easy_install mysql-python
Searching for mysql-python
Reading http://pypi.python.org/simple/mysql-python/
Reading http://sourceforge.net/projects/mysql-python/
Reading http://sourceforge.net/projects/mysql-python
Best match: MySQL-python 1.2.4b5
Downloading http://pypi.python.org/packages/source/M/MySQL-python/MySQL-python-1.2.4b5.zip#md5=4f645ed23ea0f8848be77f25ffe94ade
Processing MySQL-python-1.2.4b5.zip
Running MySQL-python-1.2.4b5/setup.py -q bdist_egg --dist-dir /var/folders/ke/ke8HKCuzGB4LMCJ1eIAGqk+++TI/-Tmp-/easy_install-W_yT0e/MySQL-python-1.2.4b5/egg-dist-tmp-GjLaFB
Downloading http://pypi.python.org/packages/source/d/distribute/distribute-0.6.28.tar.gz
Extracting in /var/folders/ke/ke8HKCuzGB4LMCJ1eIAGqk+++TI/-Tmp-/easy_install-W_yT0e/MySQL-python-1.2.4b5/temp/tmpOVVY_R
Now working in /var/folders/ke/ke8HKCuzGB4LMCJ1eIAGqk+++TI/-Tmp-/easy_install-W_yT0e/MySQL-python-1.2.4b5/temp/tmpOVVY_R/distribute-0.6.28
Building a Distribute egg in /private/var/folders/ke/ke8HKCuzGB4LMCJ1eIAGqk+++TI/-Tmp-/easy_install-W_yT0e/MySQL-python-1.2.4b5
/private/var/folders/ke/ke8HKCuzGB4LMCJ1eIAGqk+++TI/-Tmp-/easy_install-W_yT0e/MySQL-python-1.2.4b5/distribute-0.6.28-py2.6.egg
unable to execute gcc-4.0: No such file or directory
error: Setup script exited with error: command 'gcc-4.0' failed with exit status 1
Any idea on why gcc-4.0 cannot be found? I have Xcode and gcc 4.2.1 installed.

If you are on Mountain Lion ,Your problem seems to do with not having xcode command line tools installed, if you install them first from xcode then this should work

how to: pip install mysql-python on python 2.7
in order to >>>import MySQLdb
I FOLLOWED ALL THESE STEPS AND I GOT IT WORKING
For brew in case it wont let you update due to permissions.
chgrp -R admin /usr/local
chmod -R g+w /usr/local
chgrp -R admin /Library/Caches/Homebrew
chmod -R g+w /Library/Caches/Homebrew
brew update
brew doctor ## <--i did not use that
brew upgrade
ALSO I IGNORED THE Xcode update error
brew install mysql
pip install mysql-python
when i tried to import MySQLdb it threw me some errors so i followed the advise offered by the link bellow.
sudo ln -s /Users/$USERNAME/anaconda/lib/libssl.1.0.0.dylib /usr/lib/libssl.1.0.0.dylib
sudo ln -s /Users/$USERNAME/anaconda/lib/libcrypto.1.0.0.dylib /usr/lib/libcrypto.1.0.0.dylib
THE LINKS I USED
lib... issues
home bre update permission issue
install mysql with brew

Related

Error when installing RediSearch on centos 7

I am running "make setup" to install RediSearch on linux centos 7. The problem is:
make setup
Setting up system...
yum install -q -y ca-certificates
yum install -q -y curl wget
/usr/bin/python2 -m pip install --disable-pip-version-check wheel
/usr/bin/python2 -m pip install --disable-pip-version-check setuptools --upgrade
/home/andrewc/marcus/RediSearch/deps/readies/bin/enable-utf8
sed: -e expression #1, char 30: unterminated `s' command
In /home/bbbb/xxx/RediSearch/deps/readies/bin/enable-utf8:
command failed: { /home/bbbb/xxx/RediSearch/deps/readies/bin/enable-utf8; } >/tmp/tmpoqKXYK 2>&1
make: *** [Makefile:219: setup] Error 1
I have tried to reinstall Cmake but still failed to tackle the error
Running on an isolated environment (e.g., Docker container with a volume mount of your repo), you can setup and build RediSearch using:
./deps/readies/bin/getpy2
./sbin/system-setup.py
bash -l # enable toolchain
make
To diagnose the original issue, the following can be helpful:
./deps/readies/bin/getbashdb
bashdb ./deps/readies/bin/enable-utf8
Disabling enable-utf8 altogether in system-setup.py can also help, as lack of utf8 support typically causes problems only in CI systems.

"sql.h: No such file or directory" error trying to install pyodbc on raspberry pi [duplicate]

I am running Linux (2.6.18-164.15.1.el5.centos.plus) and trying to install pyodbc. I am doing pip install pyodbc and get a very long list of errors, which end in
error: command 'gcc' failed with exit status 1
I looked in /root/.pip/pip.log and saw the following:
InstallationError: Command /usr/local/bin/python -c "import setuptools; file='/home/build/pyodbc/setup.py'; execfile('/home/build/pyodbc/setup.py')" install --single-version-externally-managed --record /tmp/pip-7MS9Vu-record/install-record.txt failed with error code 1
Has anybody had a similar issue installing pyodbc?
On Ubuntu, you'll need to install unixodbc-dev:
sudo apt-get install unixodbc-dev
Install pip by using this command:
sudo apt-get install python-pip
once that is installed, you should be able to install pyodbc successfully:
pip install pyodbc
I resolved my issue by following correct directions on pyodbc - Building wiki which states:
On Linux, pyodbc is typically built using the unixODBC headers, so you will need unixODBC and its headers installed. On a RedHat/CentOS/Fedora box, this means you would need to install unixODBC-devel:
yum install unixODBC-devel
Adding one more answer on this question.
For Linux Debian Stretch release you would need to install the following dependencies:
apt-get update
apt-get install unixodbc-dev
pip install pyodbc
On Debian Slim some users mentioned they needed to add g++
apt-get update
apt-get install g++ unixodbc-dev
pip install pyodbc
Struggled with the same issue
After running:
sudo apt-get install unixodbc-dev
I was able to pip install pyodbc
Follow below steps to install pyodbc in any redhat version
yum install unixODBC unixODBC-devel
yum install gcc-c++
yum install python-devel
pip install pyodbc
I have referenced this question several times, and gone on to actually find the answer I was looking for here:
pyodbc wiki
To avoid gcc error on Ubuntu Linux, I did:
sudo aptitude install g++
I also installed the following 2 packages from Synaptic:
python-dev
tdsodbc
Execute the following commands (tested on centos 6.5):
yum install install unixodbc-dev
yum install gcc-c++
yum install python-devel
pip install --allow-external pyodbc --allow-unverified pyodbc pyodbc
According to official Microsoft docs for Ubuntu 18.04 you should run next commands:
sudo su
curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
curl https://packages.microsoft.com/config/ubuntu/18.04/prod.list > /etc/apt/sources.list.d/mssql-release.list
apt-get update
ACCEPT_EULA=Y apt-get install msodbcsql17
exit
If you are using python3.7, it is very important to run:
sudo apt-get install python3.7-dev
A easy way to install pyodbc is by using 'conda'. As conda automatically installs required dependencies including unixodbc.
conda --ugrade all (optional)
then
conda install pyodbc
it will install following packages:
libgfortran-ng: 7.2.0-hdf63c60_3 defaults
mkl: 2018.0.3-1 defaults
mkl_fft: 1.0.2-py36_0 conda-forge
mkl_random: 1.0.1-py36_0 conda-forge
numpy-base: 1.14.5-py36hdbf6ddf_0 defaults
pyodbc: 4.0.17-py36_0 conda-forge
unixodbc: 2.3.4-1 conda-forge
I had the same problem on CentOS 5.5
In addition to installing unixODBC-devel I also had to install gcc-c++
yum install gcc-c++
In my case (Amazon Linux AMI) none of the above worked. The following worked (idea from here):
Find the path to the file cc1plus. For me it was in /usr/libexec/gcc/x86_64-amazon-linux/4.8.5/cc1plus. For you it may vary a bit. Try ls -l /usr/libexec/gcc to find the proper directory name and go ahead.
Find directories in your path: echo $PATH (for me it was /sbin:/bin:/usr/sbin:/usr/bin:/opt/aws/bin)
Put a link to cc1plus in one of the directories in your PATH: sudo ln -s /PATH/TO/cc1plus /DIRinPATH/
For example in my case:
sudo ln -s /usr/libexec/gcc/x86_64-amazon-linux/4.8.5/cc1plus /usr/bin/
I needed all that, but I also needed python devel installed:
sudo yum install python-devel
How about installing pyobdc from zip file? From How to connect to Microsoft Sql Server from Ubuntu using pyODBC:
Download source vs apt-get
The apt-get utility in Ubuntu does have a version of pyODBC. (version 2.1.7).
However, it is badly out-of-date (2.1.7 vs 3.0.6) and may not work well with the newer versions of unixODBC and freetds.
This is especially important if you are trying to connect to later versions of Microsoft Sql Server (2008 onwards).
It is recommended that you use the latest versions of unixODBC, freetds and pyODBC when working with the latest Microsoft Sql Server instead of relying on packages in apt-get.
I know this is an old question, but the maintainer has a pyodbc GitHub Repo.
I also found a very good example for installing FreeTDS and setting up the config files.
Following the instructions on the GitHub docs seems to me to always be the best option. As of February, 2018, for CentOs7 (they have all flavors at the link) they say:
# Add the RHEL 6 library for Centos-7 of MSSQL driver. Centos7 uses RHEL-6 Libraries.
sudo su
curl https://packages.microsoft.com/config/rhel/6/prod.repo > /etc/yum.repos.d/mssql-release.repo
exit
# Uninstall if already installed Unix ODBC driver
sudo yum remove unixODBC-utf16 unixODBC-utf16-devel #to avoid conflicts
# Install the msodbcsql unixODBC-utf16 unixODBC-utf16-devel driver
sudo ACCEPT_EULA=Y yum install msodbcsql
#optional: for bcp and sqlcmd
sudo ACCEPT_EULA=Y yum install mssql-tools
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
source ~/.bashrc
# optional: for unixODBC development headers
sudo yum install unixODBC-devel
# the Microsoft driver expects unixODBC to be here /usr/lib64/libodbc.so.1, so add soft links to the '.so.2' files
cd /usr/lib64
sudo ln -s libodbccr.so.2 libodbccr.so.1
sudo ln -s libodbcinst.so.2 libodbcinst.so.1
sudo ln -s libodbc.so.2 libodbc.so.1
# Set the path for unixODBC
export ODBCINI=/usr/local/etc/odbc.ini
export ODBCSYSINI=/usr/local/etc
source ~/.bashrc
# Prepare a temp file for defining the DSN to your database server
vi /home/user/odbcadd.txt
[MyMSSQLServer]
Driver = ODBC Driver 13 for SQL Server
Description = My MS SQL Server
Trace = No
Server = 10.100.1.10
# register the SQL Server database DSN information in /etc/odbc.ini
sudo odbcinst -i -s -f /home/user/odbcadd.txt -l
# check the DSN installation with:
odbcinst -j
cat /etc/odbc.ini
# should contain a section called [MyMSSQLServer]
# install the python driver for database connection
pip install pyodbc
For archlinux/manjaro:
sudo pacman -S unixodbc
then:
sudo pip install pyodbc
or:
pip install pyodbc
You can upgrade your pip wheel setuptools before installing pyodbc (it won't affect the pyodbc installation) also with:
sudo python -m pip install --upgrade pip wheel setuptools
or
python -m pip install --upgrade pip wheel setuptools
I used this:
yum install unixODBC.x86_64
Depending on the version of centos could change the package, you can search like this:
yum search unixodbc
I faced with same issue. For python3.6.8 and ubuntu 16.04 none of above did not help me.
sudo apt-get install python3.6-dev
This solved my problem.
These 2 commands from here worked for me in RHEL 8
sudo dnf install redhat-rpm-config gcc-c++ python3-devel unixODBC-devel
pip3 install --user pyodbc
I have unixodbc, unixodbc-dev and python3-dev all installed, but I still get
In file included from src/buffer.cpp:12:
src/pyodbc.h:56:10: fatal error: sql.h: No such file or directory
56 | #include <sql.h>
| ^~~~~~~
compilation terminated.
error: command '/usr/bin/x86_64-unknown-linux-gnu-gcc' failed with exit code 1
gcc and g++ are installed as well.
I'm running pop-os 22.10. I've also checked that odbc.ini and odbcinst.ini exist as well and have FreeTDS installed.

Installing psycopg2 command 'gcc' failed with exit status 1

I'm trying to install psycopg2 but
pip install psycopg2 brings to error: command 'gcc' failed with exit status 1
Command line tools are installed
MacOS 10.15
This is likely because you don't have the PostgreSQL devel library installed. You have a few options:
(1) Install the binary with pip install psycopg2-binary
(2) Install PostgreSQL with HomeBrew: brew install postgresql, then pip install psycopg2.
You can probably just install the binary.
after updating the pip package error went away
To Update python3 pip package
wget https://bootstrap.pypa.io/get-pip.py
/usr/bin/python3 get-pip.py

How do I install psycopg2 for Python 3.x?

Just started Python a few days ago and I'm using PyCharm to develop a web application with Django. I have libpq-dev python-dev packages already installed, but it's still throwing me the same error:
./psycopg/psycopg.h:30:20: fatal error: Python.h: No such file or directory
which according to Google is the issue that occurs when python-dev package isn't installed. Note that I'm running the install from within the PyCharm interface for a virtualenv that I created for 3.2 and 3.3 (not sure how to run it from the terminal). Installing outside of the virtualenv still throws the same error, even when I install it from the terminal with setup.py. If I run pip install psycopg2 from the terminal, it succeeds, but it installs for Python 2.7. According to their website, they have support for up to Python 3.2.
On Ubuntu you just run this:
sudo apt-get install python3-psycopg2
Just run this using the terminal:
$ sudo apt-get install python3-dev
This way, you could use gcc to build the module you're trying to use.
Another option that seems to provide a newer version of psycopg2 than the one in the python3-psycopg2 package (at least when I wrote this):
sudo apt-get install pip3
sudo apt-get install libpq-dev
sudo pip3 install psycopg2
For most operating systems, the quickest way to install Psycopg is using the wheel package available on PyPI:
$ pip install psycopg2-binary
Check:
$ pip freeze | grep -i psycopg2
psycopg2-binary==2.9.3
This will install a pre-compiled binary version of the module which does not require the build or runtime prerequisites.
Or:
$ sudo apt-get install libpq-dev
$ pip install psycopg2
Check:
$ pip freeze | grep -i psycopg2
psycopg2==2.9.3
More info about psycopg vs psycopg-binary.

error: command 'gcc' failed with exit status 1 while installing eventlet

I wanted to install eventlet on my system in order to have "Herd" for software deployment.. but the terminal is showing a gcc error:
root#agrover-OptiPlex-780:~# easy_install -U eventlet
Searching for eventlet
Reading http://pypi.python.org/simple/eventlet/
Reading http://wiki.secondlife.com/wiki/Eventlet
Reading http://eventlet.net
Best match: eventlet 0.9.16
Processing eventlet-0.9.16-py2.7.egg
eventlet 0.9.16 is already the active version in easy-install.pth
Using /usr/local/lib/python2.7/dist-packages/eventlet-0.9.16-py2.7.egg
Processing dependencies for eventlet
Searching for greenlet>=0.3
Reading http://pypi.python.org/simple/greenlet/
Reading https://github.com/python-greenlet/greenlet
Reading http://bitbucket.org/ambroff/greenlet
Best match: greenlet 0.3.4
Downloading http://pypi.python.org/packages/source/g/greenlet/greenlet- 0.3.4.zip#md5=530a69acebbb0d66eb5abd83523d8272
Processing greenlet-0.3.4.zip
Writing /tmp/easy_install-_aeHYm/greenlet-0.3.4/setup.cfg
Running greenlet-0.3.4/setup.py -q bdist_egg --dist-dir /tmp/easy_install-_aeHYm/greenlet-0.3.4/egg-dist-tmp-t9_gbW
In file included from greenlet.c:5:0:
greenlet.h:8:20: fatal error: Python.h: No such file or directory
compilation terminated.
error: Setup script exited with error: command 'gcc' failed with exit status 1`
Why can't Python.h be found?
Your install is failing because you don't have the python development headers installed. You can do this through apt on ubuntu/debian with:
sudo apt-get install python-dev
for python3 use:
sudo apt-get install python3-dev
For eventlet you might also need the libevent libraries installed so if you get an error talking about that you can install libevent with:
sudo apt-get install libevent-dev
For Fedora:
sudo yum install python-devel
sudo yum install libevent-devel
and finally:
sudo easy_install gevent
What worked for me on CentOS was:
sudo yum -y install gcc
sudo yum install python-devel
For Redhat Versions(Centos 7) Use the below command to install Python Development Package
Python 2.7
sudo yum install python-dev
Python 3.4
sudo yum install python34-devel
Python 3.6
sudo yum install python36-devel
If the issue is still not resolved then try installing the below packages -
sudo yum install python-devel
sudo yum install openssl-devel
sudo yum install libffi-devel
On MacOS I had trouble installing fbprophet which requires pystan which requires gcc to compile. I would consistently get the same error: command 'gcc' failed with exit status 1
I think I fixed the problem for myself thus:
I used brew install gcc to install the newest version, which ended up being gcc-8
Then I made sure that when gcc ran it would use gcc-8 instead.
It either worked because I added alias gcc='gcc-8 in my .zshrc (same as .bashrc but for zsh), or because I ran export PATH=/usr/local/bin:$PATH (see comment)
Also: all my attempts were inside a virtual environment and I only succeeded by installing fbprophet globally (with pip), but still no success inside a venv
This is an old post but I just run to the same problem on AWS EC2 installing regex. This working perfectly for me
sudo yum -y install gcc
and next
sudo yum -y install gcc-c++
If it is still not working, you can try this
sudo apt-get install build-essential
in my case, it solved the problem.
try this :
sudo apt-get install libblas-dev libatlas-base-dev
I had a similar issue on Ubuntu 14.04. For me the following Ubuntu packages
On MacOS I also had problems trying to install fbprophet which had gcc as one of its dependencies.
After trying several steps as recommended by #Boris the command below from the Facebook Prophet project page worked for me in the end.
conda install -c conda-forge fbprophet
It installed all the needed dependencies for fbprophet. Make sure you have anaconda installed.
This page is gonna save your life, for all further lib issues that are forthcoming,
For Alpine(>=3.6), use
apk --update --upgrade add gcc musl-dev jpeg-dev zlib-dev libffi-dev cairo-dev pango-dev gdk-pixbuf-dev
For CentOS 7.2:
LSB Version: :core-4.1-amd64:core-4.1-noarch
Distributor ID: CentOS
Description: CentOS Linux release 7.2.1511 (Core)
Release: 7.2.1511
Codename: Core
Install eventlet:
sudo yum install python-devel
sudo easy_install -ZU eventlet
Terminal info:
[root#localhost ~]# easy_install -ZU eventlet
Searching for eventlet
Reading http://pypi.python.org/simple/eventlet/
Best match: eventlet 0.19.0
Downloading https://pypi.python.org/packages/5a/e8/ac80f330a80c18113df0f4f872fb741974ad2179f8c2a5e3e45f40214cef/eventlet-0.19.0.tar.gz#md5=fde857181347d5b7b921541367a99204
Processing eventlet-0.19.0.tar.gz
Running eventlet-0.19.0/setup.py -q bdist_egg --dist-dir /tmp/easy_install-Hh9GQY/eventlet-0.19.0/egg-dist-tmp-rBFoAx
Adding eventlet 0.19.0 to easy-install.pth file
Installed /usr/lib/python2.6/site-packages/eventlet-0.19.0-py2.6.egg
Processing dependencies for eventlet
Finished processing dependencies for eventlet
For openSUSE 42.1 Leap Linux use this
sudo zypper install python3-devel
I am using MacOS catalina 10.15.4. None of the posted solutions worked for me. What worked for me is:
>> xcode-select --install
xcode-select: error: command line tools are already installed, use "Software Update" to install updates
>> env LDFLAGS="-I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib" pip install psycopg2==2.8.4
Collecting psycopg2==2.8.4
Using cached psycopg2-2.8.4.tar.gz (377 kB)
Installing collected packages: psycopg2
Attempting uninstall: psycopg2
Found existing installation: psycopg2 2.7.7
Uninstalling psycopg2-2.7.7:
Successfully uninstalled psycopg2-2.7.7
Running setup.py install for psycopg2 ... done
Successfully installed psycopg2-2.8.4
use pip3 for python3
if you are on Mac as myself, try this in your terminal: xcode-select --install
Then accept the installation request, and it works afterwards as described in this issue
Build from source and install, this is fixed in the latest release (10.3+):
mkdir -p /tmp/install/netifaces/
cd /tmp/install/netifaces && wget -O "netifaces-0.10.4.tar.gz" "https://pypi.python.org/packages/source/n/netifaces/netifaces-0.10.4.tar.gz#md5=36da76e2cfadd24cc7510c2c0012eb1e"
tar xvzf netifaces-0.10.4.tar.gz
cd netifaces-0.10.4 && python setup.py install
Similarly I fixed it like this (notice python34):
sudo yum install python34-devel
sudo apt install gcc
It works for PyCharm on Ubuntu 20.10.
If you are migrating to a more modern version of python3 e.g. python3.5 to python3.8 You may want to check/upgrade the versions of the library that are failing if you have already installed the recommended libraries to handle gcc building python3-dev + other libraries as suggested.
It depends on the package. Some versions of the packages may not be supported on later versions of python3.

Categories