Related
First off, yeah, I've already seen this:
pip install mysql-python fails with EnvironmentError: mysql_config not found
The problem
I am trying to use Django on a Google App Engine project. However, I haven't been able to get started as the server fails to start properly due to:
ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
ImproperlyConfigured: Error loading MySQLdb module: No module named MySQLdb
I did some research and it all pointed to having to install Mysql-python, as apparently it isn't on my system. I actually tried uninstalling it and got this:
Cannot uninstall requirement mysql-python, not installed
Whenever I actually do try to install via:
sudo pip install MySQL-python
I get an error stating:
raise EnvironmentError("%s not found" % (mysql_config.path,))
EnvironmentError: mysql_config not found
I've already tried running:
export PATH=$PATH:/usr/local/mysql/bin
but that didn't seem to help, as I ran the installation command again and it still failed.
Any ideas?
Please note I'm not in a virtualenv.
Ok, well, first of all, let me check if I am on the same page as you:
You installed python
You did brew install mysql
You did export PATH=$PATH:/usr/local/mysql/bin
And finally, you did pip install MySQL-Python (or pip3 install mysqlclient if using python 3)
If you did all those steps in the same order, and you still got an error, read on to the end, if, however, you did not follow these exact steps try, following them from the very beginning.
So, you followed the steps, and you're still geting an error, well, there are a few things you could try:
Try running which mysql_config from bash. It probably won't be found. That's why the build isn't finding it either. Try running locate mysql_config and see if anything comes back. The path to this binary needs to be either in your shell's $PATH environment variable, or it needs to be explicitly in the setup.py file for the module assuming it's looking in some specific place for that file.
Instead of using MySQL-Python, try using 'mysql-connector-python', it can be installed using pip install mysql-connector-python. More information on this can be found here and here.
Manually find the location of 'mysql/bin', 'mysql_config', and 'MySQL-Python', and add all these to the $PATH environment variable.
If all above steps fail, then you could try installing 'mysql' using MacPorts, in which case the file 'mysql_config' would actually be called 'mysql_config5', and in this case, you would have to do this after installing: export PATH=$PATH:/opt/local/lib/mysql5/bin. You can find more details here.
Note1: I've seen some people saying that installing python-dev and libmysqlclient-dev also helped, however I do not know if these packages are available on Mac OS.
Note2: Also, make sure to try running the commands as root.
I got my answers from (besides my brain) these places (maybe you could have a look at them, to see if it would help): 1, 2, 3, 4.
I hoped I helped, and would be happy to know if any of this worked, or not. Good luck.
I had been debugging this problem forever - 3 hours 17 mins. What particularly annoyed me was that I already had sql installed on my system through prior uni work but pip/pip3 wasn't recognising it. These threads above and many other I scoured the internet for were helpful in eluminating the problem but didn't actually solve things.
ANSWER
Pip is looking for mysql binaries in the Homebrew Directory which is located relative to Macintosh HD #
/usr/local/Cellar/
so I found that this requires you making a few changes
step 1: Download MySql if not already done so https://dev.mysql.com/downloads/
Step 2: Locate it relative to Macintosh HD and cd
/usr/local/mysql/bin
Step 3: Once there open terminal and use a text editor of choice - I'm a neovim guy myself so I typed (doesn't automatically come with Mac... another story for another day)
nvim mysql_config
Step 4: You will see at approx line 112
# Create options
libs="-L$pkglibdir"
libs="$libs -l "
Change to
# Create options
libs="-L$pkglibdir"
libs="$libs -lmysqlclient -lssl -lcrypto"
*you'll notice that this file has read-only access so if your using vim or neovim
:w !sudo tee %
Step 5: Head to the home directory and edit the .bash_profile file
cd ~
Then
nvim .bash_profile
and add
export PATH="/usr/local/mysql/bin:$PATH"
to the file then save
Step 6: relative to Macintosh HD locate paths and add to it
cd /private/etc/
then
nvim paths
and add
/usr/local/mysql/bin
*you'll again notice that this file has read-only access so if your using vim or neovim
:w !sudo tee %
then
cd ~
then refresh the terminal with your changes by running
source .bash_profile
Finally
pip3 install mysqlclient
And Viola. Remember it's a vibe.
If you don't want to install full mysql, we can fix this by just installing mysql-client
brew install mysql-client
Once cmd is completed it will ask to add below line to ~/.bash_profile:
echo 'export PATH="/usr/local/opt/mysql-client/bin:$PATH"' >> ~/.bash_profile
Close terminal and start new terminal and proceed with pip install mysqlclient.
I am running Python 3.6 on MacOS Catalina. My issue was that I tried to install mysqlclient==1.4.2.post1 and it keeps throwing mysql_config not found error.
This is the steps I took to solve the issue.
Install mysql-connector-c using brew (if you have mysql already install unlink first brew unlink mysql) - brew install mysql-connector-c
Open mysql_config and edit the file around line 112
# Create options
libs="-L$pkglibdir"
libs="$libs -lmysqlclient -lssl -lcrypto"
brew info openssl - this will give you more information on what needs to be done about putting openssl in PATH
in relation to step 3, you need to do this to put openssl in PATH - echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile
for compilers to find openssl - export LDFLAGS="-L/usr/local/opt/openssl/lib"
for compilers to find openssl - export CPPFLAGS="-I/usr/local/opt/openssl/include"
Also this happens when I was installing mysqlclient,
$ pip install mysqlclient
As user3429036 said,
$ brew install mysql
If you have installed mysql using Homebrew by specifying a version then mysql_config would be present here. - /usr/local/Cellar/mysql#5.6/5.6.47/bin
you can find the path of the sql bin by using ls command in /usr/local/ directory
/usr/local/Cellar/mysql#5.6/5.6.47/bin
Add the path to bash profile like this.
nano ~/.bash_profile
export PATH="/usr/local/Cellar/mysql#5.6/5.6.47/bin:$PATH"
This answer is for MacOS users who did not install from brew but rather from the official .dmg/.pkg. That installer fails to edit your PATH, causing things to break out of the box:
All MySQL commands like mysql, mysqladmin, mysql_config, etc cannot be found, and as a result:
the "MySQL Preference Pane" fails to appear in System Preferences, and
you cannot install any API that communicates with MySQL, including mysqlclient
What you have to do is appending the MySQL bin folder (typically /usr/local/mysql/bin in your PATH by adding this line in your ~/.bash_profile file:
export PATH="/usr/local/mysql/bin/:$PATH"
You should then reload your ~/.bash_profile for the change to take effect in your current Terminal session:
source ~/.bash_profile
Before installing mysqlclient, however, you need to accept the XcodeBuild license:
sudo xcodebuild -license
Follow their directions to sign away your family, after which you should be able to install mysqlclient without issue:
pip install mysqlclient
After installing that, you must do one more thing to fix a runtime bug that ships with MySQL (Dynamic Library libmysqlclient.dylib not found), by adding this line to your system dynamic libraries path:
export DYLD_LIBRARY_PATH=/usr/local/mysql/lib/:$DYLD_LIBRARY_PATH
brew install mysql added mysql to /usr/local/Cellar/..., so I needed to add :/usr/local/Cellar/ to my $PATH and then which mysql_config worked!
The problem in my case was that I was running the command inside a python virtual environment and it didn't had the path to /usr/local/mysql/bin though I have put it in the .bash_profile file. Just exporting the path in the virtual env worked for me.
For your info sql_config resides inside bin directory.
Install brew or apt-get is also not easy for me so I downloaded mysql via: https://dev.mysql.com/downloads/connector/python/, installed it. So I can find mysql_config int this directory: /usr/local/mysql/bin
the next step is:
export PATH=$PATH:/usr/local/mysql/bin
pip install MySQL-python==1.2.5
I'm still getting familiar with python and python eggs so sorry if this is a stupid question. I want to know why easy_install appears to install the egg for the whole server to use rather than just locally for the account that tried to install it.
I created a simple helloworld module/egg and tried to install it on a server I have an account on. However, the account doesn't have root access (it's a tester's account). I get a "Permission denied" error message when installing it. When installing the module, it is trying to install to /usr/local/lib/python2.7/site_packages/blah/blah/blah. It's pretty clear it's b/c I don't have root access to write to this location.
easy_install hello-1.0-py2.7.egg
On my laptop (my account has root access), I can run the cmd above and see the module is installed by running 'pip freeze'. The slight difference is that Anaconda is running/installed on my laptop and seemed to be doing the package management for me.
So back to my original question; how does easy_install install eggs that we create ourselves? I was hoping/assuming it would install the module in my tester's account and not to /usr/local/lib/blha/blah/blah for all users to use/access. Is this an incorrect assumption? If this is incorrect thinking, how would someone install a module/egg where the account doesn't have root access? Thanks.
Se per easy_install or pip as a limited user? you'll want to use the --prefix option to easy_install and/or -d or -s.
I believe you could do something as simple as:
easy_install --prefix=$HOME hello-1.0-py2.7.egg
An option is to use virtualenv which allows you to create multiple virtual environments for Python, each with its own set of libraries.
Just create a virtualenv and then you can then install your module within it without requiring write access to the system Python installation.
There is a tutorial here: http://simononsoftware.com/virtualenv-tutorial/, but simply install virtualenv then:
$ cd $HOME
$ virtualenv test
$ cd test
$ source bin/activate
$ easy_install /path/to/hello-1.0-py2.7.egg
The package should be installed into ~/test/lib/python2.7/site-packages
I was trying to install postgres for a tutorial, but pip gives me error:
pip install psycopg
A snip of error I get:
Error: pg_config executable not found.
Please add the directory containing pg_config to the PATH
or specify the full executable path with the option:
python setup.py build_ext --pg-config /path/to/pg_config build ...
or with the pg_config option in 'setup.cfg'.
Where is pg_config in my virtualenv? How to configure it? I'm using virtualenv because I do not want a system-wide installation of postgres.
On the Mac, if you're using Postgres.app, the pg_config file is in your /Applications/Postgres.app/Contents/Versions/<current_version>/bin directory. That'll need to be added to your system path to fix this error, like this:
export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/<current_version>/bin
So for example, if the current Postgres.app version is 9.5, this export line would be:
export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/9.5/bin
With more recent versions of the Postgres.app (> 9.5?), you can simply add "latest" in place of the version number, like so:
export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/latest/bin
On Mac, the solution is to install postgresql:
brew install postgresql
On CentOS, the solution is to install postgresql-devel:
sudo yum install postgresql-devel
pg_config is in postgresql-devel package
I totally agree with john hight that most of posted answers are totally offtopic assuming the OP exactly specified need of using virtualenv.
For me the answer was runing following command in prompt while having activated virtualenv:
export PATH="/Applications/Postgres.app/Contents/Versions/9.4/bin:$PATH"
(notice that part 9.4 stands for version and may vary)
or if you want to use the latest installed version of Postgres:
export PATH="/Applications/Postgres.app/Contents/Versions/latest/bin:$PATH"
and then:
pip install psycopg2
goes sucesfully assuming you have installed postgres. And if not, then remember that the best and recomended solution is to use: Postgres.app
Don't forget that your $PATH variable in the virtual environment != your global $PATH variable. You can confirm this with 'echo $PATH' in your virtualenv and also in a new shell. So, unless you want to install PostgreSQL as a unique instance inside your virtual environment (not a thing worth doing, imo), you'll need to modify the $PATH variable within the virtualenv to include the path to your global installation (which will solve your missing pg_config error).
Here are the steps:
1.) In a new shell, type 'which pg_config'. This will return the path. Copy it. In my case, the path looked like this: /Applications/Postgres.app/Contents/Versions/9.3/bin
2.) Back in your virtualenv shell, type 'export PATH=/your-path-to-pg_config:$PATH'
3.) Then, still within the virtualenv, 'pip install psycopg2'
If all goes according to plan, this will install psycopg2 within the virtual environment, but the installation will refer to your Global PostgreSQL installation. In my case, this Global installation was installed via Postgres.App, hence the path. I prefer this method of working with psycopg2 as it means I can use the database easily within any virtualenv rather than only within the defined virtual environment.
Hope this helps anyone who arrives here. For Google juice, here's the explicit (and vague) error language returned when you run into this problem:
Command python setup.py egg_info failed with error code 1
Here's how I was able to solve this problem on my Mac (OSX 10.9):
brew update
brew install --force ossp-uuid
brew install postgresql
pip install psycopg
I got a CLANG error when I tried pip install psycopg (an LLVM 5.1 issue), so I had to install psycopg with this command instead:
ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future pip install psycopg
It's similar to Mingyu's solution, but there are enough differences that I thought it was worth sharing.
you must configure path postgresql:
export PATH=$PATH:/Library/PostgreSQL/11/bin
after, you must install requirements:
pip3 install -r requirements
For OS X El Capitan (10.11.6) + brew + virtualenv + PostgreSQL 9.5:
After installing PostgreSQL 9.5:
brew install postgresql#9.5
Then, open your terminal and execute:
export PATH=$PATH:/usr/local/opt/postgresql\#9.5/bin/
pip install psycopg2
This error is caused when the build tools can't find the Postgresql libraries.
Often it's required to instruct psycopg2 how to find the pg_config binary, you can:
add the path to pg_config in your shell path (/usr/local/pgsql/bin/)
or edit the setup.cfg file in the psycopg2 source folder and provide
the full path to pg_config on the line that starts with pg_config=
pg_config=/usr/local/pgsql/bin/pg_config
the above is an example, you can do locate pg_config to find out where it resides, or simply type which pg_config and it should tell you the path.
Less often the error comes from not having postgresql installed on your system. If so, download and build postgres, or download a pre-built psycopg2 binary for OS X.
virtualenv is for python packages. I don't think you'll be able to contain postgres inside a virtualenv. The error message you're seeing is presumably because you haven't yet installed postgres. The psycopg2 install script is looking for postgres files (in this case pg_config) and not finding them because it is not installed. postgres can't be installed using pip or virtualenv.
On Windows I installed postgres manually from http://www.enterprisedb.com/products-services-training/pgdownload#windows.
After that the same command works.
In addition to the answers provided by #bkev and #andi, according to the documentation on Postgres.app, you should add the following to your bash_profile on Mac:
export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/latest/bin
Note that, there is no hard-coded version number. I wanted to add this as a comment to above answers, but I don't have enough rep for this.
If you're using postgresql 9.4, the file is located in
/usr/pgsql-9.4/bin/pg_config
The name of the package is
postgresql94-9.4.9-1PGDG.rhel6.x86_64
to add pg_config to your PATH, do the following
PATH=$PATH:/usr/pgsql-9.4/bin/
If you don't have to use the psycopg driver specifically, switch to the pg8000 driver. It's pure Python and less finicky.
On Ubuntu I just needed the postgres dev package:
sudo apt-get install postgresql-server-dev-all
Mine was located in /Library/PostgreSQL/9.4/bin
export PATH=$PATH:/Library/PostgreSQL/9.4/bin
pip install psycopg2-binary
Binary install will work in virtual env, it Will have lib files necessary to work in virtual environment
I added to $PATH postgres, but had similar issue. After made a change in Dockerfile and installed through bin/sh, an install passed. It could be also links in with python alpine version. Not alpine version had not any problem during installation.
# syntax=docker/dockerfile:1
FROM python:3.11-rc-alpine
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
WORKDIR /code
COPY requirements.txt /code/
RUN #pip install --upgrade pip
RUN /bin/sh -c pip install -r requirements.txt
RUN #pip install -r requirements.txt
COPY . /code/
Long story short, when I write the following:
sudo easy_install MySQL-python
I get the error
EnvironmentError: mysql_config not found
All right, so there are plenty of threads and the like on how to fix that, so I run this code:
export PATH=$PATH:/usr/local/mysql/bin
Then I rerun my sudo code:
sudo easy_install MySQL-python
Then I get the following error.
Setup script exited with error: command 'llvm-gcc-4.2' failed with exit status 1
Google/Stack Overflow that, and I am told to download a GCC package which I did the other day, 200 MB's or there-abouts and still no fix.
At this point I am lost, they say insanity is doing the same thing over and over while expecting a different result. Well, I've continually run the aforementioned code expecting a different result, so I'm not to far away from going insane.
At this point in my Python career, I am new to this, but I am willing to try pretty much anything to get this up and running.
If it helps I am officially running, Mac OS X 10.7.5, and I do have MAMP installed (is that an issue?)
Also, the other day when I was trying all of this for the first time I installed (reinstalled?) MySQL, so I'm really in a tough spot at this point.
Is there a fix?
I've racked my brain, searched Google, read Stack Overflow, and spent hours trying to figure this out to no avail.
Here's what I would install, especially if you want to use homebrew:
XCode and the command line tools (as suggested by #7stud, #kjti)
Install homebrew
brew install mysql-connector-c
pip install mysql-python
Another option is to use pymysql it is a pure Python client connection to MySQL so you don't have to mess around with compiling, a good exercise, but it can be frustrating if you are just trying to get something done. pymysql follows the same API as MySQLdb, it can essentially be used as a drop in replacement.
Also, it used to be that MySQLdb, did not work with Python 3, but this may have changed, pymysql didn't have that problem which also induced me to switch, this may have changed though. pymysql can be slower than MySQLdb but you'll have to see if you notice that, it is also under a different license (MIT for pymysql, GPL for MySQLdb)
For Python 3+ the mysql-python library is broken. Instead, use the mysqlclient library. Install with: pip install mysqlclient
It is a fork of mysql-python (also known as MySQLdb) that supports Python 3+
This library talks to the MySQL client's C-interface, and is faster than the pure-python pymysql libray.
Note: you will need the mysql-developer tools installed. An easy way to do this on a Mac is to run
brew install mysql-connector-c
to delegate this task to homebrew. If you are on linux, you can install these via the instructions at the mysqlclient github page.
Install mysql via homebrew, then you can install mysql python via pip.
pip install MySQL-python
It works for me.
I am using OSX -v 10.10.4. The solution above is a quick & easy.
Happening OSX does not have the connection library by default.
First you should install the connector:
brew install mysql-connector-c
Then install with pip mysql
pip install mysql-python
To install PyMySQL
install pip => sudo easy_install pip
install PyMySQL=> sudo easy_install-3.7 pymysql
terminal command to check whether installed or not => pip3 list
or
install PyMySQL=> sudo pip install PyMySQL
terminal command to check whether installed or not => pip3 list
MySQL
The macOS Sierra Public Beta’s didn’t play well with MySQL 5.7.x, but these issues are now resolved by using MySQL 5.7.16
MySQL doesn’t come pre-loaded with macOS Sierra and needs to be dowloaded from the MySQL site.
( https://dev.mysql.com/downloads/mysql/)
The latest version of MySQL 5.7.16 does work with the public release of macOS.
If you already have MySQL 5.7 and you have upgraded OS from El Capitan to Sierra I expect that to be ok, but will be interested if anyone comments on that.
Use the Mac OS X 10.11 (x86, 64-bit), DMG Archive version (works on macOS Sierra).
If you are upgrading from a previous OSX and have an older MySQL version you do not have to update it. One thing with MySQL upgrades always take a data dump of your database in case things go south and before you upgrade to macOS Sierra make sure your MySQL Server is not running.
When downloading you don’t have to sign up, look for » No thanks, just take me to the downloads! – go straight to the download mirrors and download the software from a mirror which is closest to you.
Once downloaded open the .dmg and run the installer.
When it is finished installing you get a dialog box with a temporary mysql root password – that is a MySQL root password not a macOS admin password, copy and paste it so you can use it. But I have found that the temporary password is pretty much useless so we’ll need to change it straight away.
You are also told:
If you lose this password, please consult the section How to Reset the Root Password in the MySQL reference manual.(https://dev.mysql.com/doc/refman/5.7/en/resetting-permissions.html)
Change the MySQL root password
Note that this is not the same as the root or admin password of macOS – this is a unique password for the mysql root user, use one and remember/jot down somewhere what it is.
Stop MySQL
sudo /usr/local/mysql/support-files/mysql.server stop
if stop throws permission issue
Check the error file first.
tail -f /usr/local/mysql/data/*.err
Do a complete shut down or kill the process. Confirm that no mysql process is running
mysqladmin -uroot shutdown
sudo killall mysqld
ps -ef | grep mysql
Give permisiions
sudo chown -RL root:mysql /usr/local/mysql
sudo chown -RL mysql:mysql /usr/local/mysql/data
chmod -R 755 /usr/local/mysql/data
chmod -R 755 /usr/local/mysql/data/accountname.local.pid
or Right click->get info and change the permission for
/usr/local/mysql/data
/usr/local/mysql/data/Pushparajas-MacBook-Pro.local.pid
Start mysql
sudo mysql.server start
Start it in safe mode:
sudo mysqld_safe --skip-grant-tables
This will be an ongoing command until the process is finished so open another shell/terminal window, and log in with a password which is temporary generated:
mysql -u root -p
FLUSH PRIVILEGES;
ALTER USER 'root'#'localhost' IDENTIFIED BY 'MyNewPass'
;
Change the lowercase ‘MyNewPass’ to what you want – and keep the single quotes.
\q
Start MySQL
sudo /usr/local/mysql/support-files/mysql.server start
Starting MySQL
You can then start the MySQL server from the System Preferences or via the command line.
Command line start MySQL.
sudo /usr/local/mysql/support-files/mysql.server start
To find the MySQL version from the terminal, type at the prompt:
/usr/local/mysql/bin/mysql -v -uroot -p
This also puts you in to a shell interactive dialogue with mySQL, type \q to exit.
After installation, in order to use mysql commands without typing the full path to the commands you need to add the mysql directory to your shell path, (optional step) this is done in your “.bash_profile” file in your home directory, if you don’t have that file just create it using vi or nano:
cd ; nano .bash_profile
export PATH="/usr/local/mysql/bin:$PATH"
The first command brings you to your home directory and opens the .bash_profile file or creates a new one if it doesn’t exist, then add in the line above which adds the mysql binary path to commands that you can run. Exit the file with type “control + x” and when prompted save the change by typing “y”. Last thing to do here is to reload the shell for the above to work straight away.
source ~/.bash_profile
mysql -v
You will get the version number again, just type “q” to exit.
Fix the 2002 MySQL Socket error
Fix the looming 2002 socket error – which is linking where MySQL places the socket and where macOS thinks it should be, MySQL puts it in /tmp and macOS looks for it in /var/mysql the socket is a type of file that allows mysql client/server communication.
sudo mkdir /var/mysql
sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock
phpMyAdmin
uncomment below line in httpd.conf file
LoadModule php7_module libexec/apache2/libphp7.so
First fix the 2002 socket error if you haven’t done so from the MySQL section-
sudo mkdir /var/mysql
sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock
Download phpMyAdmin, (https://www.phpmyadmin.net/downloads/) the zip English package will suit a lot of users, then unzip it and move the folder with its contents into the document root level(~/Sites/) renaming folder to ‘phpmyadmin’.
Make the config folder
mkdir ~/Sites/phpmyadmin/config
Change the permissions
chmod o+w ~/Sites/phpmyadmin/config
Run the set up in the browser
http://localhost/~username/phpmyadmin/setup/ or http://localhost/phpmyadmin/setup/
You need to create a new localhost mysql server connection, click new server.
Switch to the Authentication tab and set the local mysql root user and the password.
Add in the username “root” (maybe already populated, add in the password that you set up earlier for the MySQL root user set up, click on save and you are returned to the previous screen.
(This is not the macOS Admin or root password – it is the MySQL root user).
Make sure you click on save, then a config.inc.php is now in the /config directory of phpmyadmin directory, move this file to the root level of /phpmyadmin and then remove the now empty /config directory.
In the latest phpmyadmin, download the config.inc.php and place in phpmyadmin directory.
If you want to setup new server move config.inc.php to some location and try http://localhost/~username/phpmyadmin/setup
Now going to http://localhost/~username/phpmyadmin/ will now allow you to interact with your MySQL databases.
To upgrade phpmyadmin just download the latest version and copy the older ‘config.inc.php‘ from the existing directory into the new folder and replace – backup the older one just in case.
Permissions
To run a website with no permission issues it is best to set the web root and its contents to be writeable by all, since it’s a local development it shouldn’t be a security issue.
Lets say that you have a site in the User Sites folder at the following location ~/Sites/testsite you would set it to be writeable like so:
sudo chmod -R a+w ~/Sites/testsite
If you are concerned about security then instead of making it world writeable you can set the owner to be Apache _www but when working on files you would have to authenticate more as admin you are “not” the owner, you would do this like so:
sudo chown -R _www ~/Sites/testsite
This will set the contents recursively to be owned by the Apache user.
If you had the website stored at the System level Document root at say ~/Sites/testsite then it would have to be the latter:
sudo chown -R _www ~/Sites/testsite
Another easier way to do this if you have a one user workstation is to change the Apache web user from _www to your account.
That’s it! You now have the native AMP stack running on top of macOS Sierra.
Ref Link - https://coolestguidesontheplanet.com/get-apache-mysql-php-and-phpmyadmin-working-on-macos-sierra/#ssu
On Mojave, I ran into errors with finding the SSL libraries, here's what finally worked without having to modify mysql_config:
sudo pip install MySQL-Python --global-option=build_ext --global-option="-I/usr/local/opt/openssl/include" --global-option="-L/usr/local/opt/openssl/lib"
Hopefully that will save someone a few hours of heartache
It's time to be a big boy and install from source. Try this:
1) Download the MySQL-python-1.X.X.tar.gz file(by default will go to your Downloads directory)
2) Open a Terminal window and cd to the Downloads directory.
3) Unzip the file you downloaded:
~/Downloads$ tar xfvz MySQL-python-1.X.X.tar.gz
That will create a directory inside your Downloads directory called MySQL-python
4) cd into the newly created directory.
5) Typically, you just open the file called README or INSTALL and follow the instructions--but generally to install a python module all you do is:
$ sudo python setup.py install
If you care to look, there should be a file called setup.py inside your newly created MySQL-python directory, and you are invoking that program to install the module.
Also note that this:
export PATH=$PATH:/usr/local/mysql/bin
is not permanent if you did that on the command line. You need to put that line in a file called .bashrc in your home directory (~/ or equivalently /Users/YOUR_USER_NAME). To see if .bashrc already exists(it's a hidden file), issue the command:
$ ls -al
and look for .bashrc. If .bashrc doesn't exist, then create it.
As others mentioned before me....getting Python to work with MySQL on a Mac is a ?##$#&%^!! nightmare.
Installed Django framework on Mac OS 10.7.5 initially from the original Django website and when the MySQLdb didn't work, and after many hours googling and trying solutions from SO, I have installed the Django stack from BitNami http://bitnami.com/stack/django
Still, got the issues mentioned above and then some more...
What helped me eventually is what Josh recommends on his blog: http://joshbranchaud.com/blog/2013/02/10/Errors-While-Setting-Up-Django.html
Now Python 2.7 is finally connected to MySQL 5.5
The issue you are having is that the gcc compiler is not installed on your Mac. It will be installed if you have installed XCode. You will have to download gcc complier and install it manually. Follow the below link and download it -
https://github.com/downloads/kennethreitz/osx-gcc-installer/GCC-10.7-v2.pkg
I once had this problem installing Ruby 1.9 and I had to compile ruby for myself because Mountain Lion wasn't supported at that time. After installing the package, verify the install by the command gcc.
I am using Python 2.7.11 :: Anaconda 2.3.0 (x86_64) on Mac OS X 10.11.4 15E65.
You may want to follow the steps below:
Install homebrew
Open a terminal and run: brew install mysql-connector-c
pip install mysql-python
Then the Anaconda will have the mysql-python installed and you can start with MySQLdb then.
Good luck. Thanks.
Above all, I can't solve it. But I add file to /usr/local/include solve it.
https://github.com/peterlee0304/MySQL-Python/blob/master/my_config.h
In /usr/local/include, add a my_config.h file.
Then pip install MySQL-Python
Solve it!
What worked for me is:
LDFLAGS=-L/usr/local/opt/openssl/lib pip install mysql-python
the below may be help.
brew install mysql-connector-c
CFLAGS =-I/usr/local/Cellar/mysql-connector-c/6.1.11/include pip install MySQL-python
brew unlink mysql-connector-c
I used PyMySQL instead and its working fine!
sudo easy_install-3.7 pymysql
I'm trying to install the following as per the learnpythonthehardway tutorial:
pip from http://pypi.python.org/pypi/pip
distribute from http://pypi.python.org/pypi/distribute
nose from http://pypi.python.org/pypi/nose/
virtualenv from http://pypi.python.org/pypi/virtualenv
I've visited these links and clicked the download button; each file is in my downloads folder now, and I unarchive/unzipped them- not sure what this means but it seemed required. Are they "installed"? If not, what does it mean to really install them? I've tried typing nosetests in the terminal (as the book says you should), as well as tried easy_install but that doesn't seem to work. It appears my understanding is limited in a number of ways here.
I get the following -bash: nosetests: command not found, but am trying to get:
nosetests . ---------------------------------------------------------------------- Ran 1 test in 0.007s
OK
This works on mac, it may work on linux
1)Open terminal (Be prepared to enter your password)
2)Type: sudo easy_install pip
3)Type: sudo pip install distribute
4)Type: sudo pip install nose
5)Type: sudo pip install virtualenv
Hope that helps, cheers!
They are not yet installed.
Each has its own vagaries about how exactly the install process works and in fact some of those packages will include the other packages with them. I.e.
"If you use virtualenv, a copy of pip will be automatically be
installed in each virtual environment you create."
http://pypi.python.org/pypi/pip
As a relatively new python user myself, (and having gone thru a similar process not long ago) I am eagerly awaiting the more complete answers that come back for this one.
Find out where the nosetests script is. On OSX:
/usr/local/share/nosetests
Execute directly, or set up a bash alias, perhaps in .bash_profile:
alias nosetests='/usr/local/share/python/nosetests'
alias nosetests3='/usr/local/share/python3/nosetests'
You were on the right track, but the package is actually called "nose". The documentation for nose (nosetests is the script) can be found here:
https://nose.readthedocs.org/en/latest/
The short answer is that you have 2 basic options: easy_install or pip. Install using setuptools/distribute: easy_install nose. Install using pip: pip install nose
Install Python 2.7 and after just do this (only on Windows - Windows PowerShell):
Setup PATH env:
C:\Python27\;C:\Python27\Scripts\", "User"
pip is already installed
3.
.\pip install distribute
4.
.\pip install nose
5.
.\pip install virtualenv