Primeiro eu abriria um terminal e:
python <enter>
import sys <enter>
print sys.path <enter>
Sua biblioteca relevante está no caminho?
Na teoria MacPorts (@fideli acima) há também outro PMS chamado Homebrew link . Funciona surpreendentemente bem para o gerenciamento de pacotes no Mac.
No entanto, eu fiz isso (totalmente compilado) no passado com mais dor que eu estava fazendo em um G5 PPC64. A maneira como eu consegui que funcionasse era compilar Python, Python-MySQL, MySQL e mod_wsgi todos a partir do código-fonte. É possível, mas a grande armadilha que as pessoas enfrentam é a falta de correspondência de arquitetura entre os pacotes. Aqui estão as minhas notas de fazê-lo em um PPC. Extraia o que puder e, se precisar de ajuda extra, por favor nos avise. A parte chave para prestar atenção é exportar o ARCHFLAGS antes de cada compilação. Isso garantirá que você tenha uma correspondência de arquitetura. Como eu disse o seguinte é o que eu fiz para um ambiente PPC64, no entanto, você pode simplesmente substituir os archs por sua plataforma relevante, por exemplo, x86_64 desde que você está executando 10.6 nós sabemos que você tem um chip Intel. Você pode ignorar as versões exatas do software, pois elas não devem ser tão relevantes. Espero que isso seja útil para você.
Sidenote: Parece que o seu MySQL é de 32 bits, mas o seu Python é de 64 bits.
Detalhes iniciais:
- A plataforma de destino foi o OSX 10.5.8 (PPC64).
- O objetivo era compilar todas as distribuições como binários "Fat", o que significa que ele suportará x86, PPC, PPC64 e x86_64.
- Manipule isso como achar melhor para sua plataforma de segmentação.
This file will go through the steps of how to
install Python, MySQL, MySQLdb-Python, and
mod_wsgi on clean MacOSX 10.5.8 all 64Bit
#################################################
1.Download Python Source -> Plan 2.7
2.Download MySQL Source -> Plan 5.1.50
3.Download MySQLdb-Python Source -> Plan 1.2.3
4.Download mod_wsgi -> Plan 1.3.3
Untar all of the above and prep for Python
#################################################
1. export ARCHFLAGS='-arch i386 -arch ppc -arch ppc64 -arch x86_64'
2. ./configure --with-framework-name=Python64 --with-universal-archs=all --enable-framework --enable-universalsdk=/ MACOSX_DEPLOYMENT_TARGET=10.5
3. make
4. sudo make install
5. Add to /etc/paths
-> /usr/local/bin
6. Modify /etc/profile
-> if [ -x /usr/libexec/path_helper ]; then
-> PATH=""
-> eval '/usr/libexec/path_helper -s' <- Be sure to note these are backticks ie Shell expansion
-> fi
7. Reboot the system
8. Test Python Intereter is @2.7
Compile and Install mod_wsgi
#################################################
1. export ARCHFLAGS='-arch i386 -arch ppc -arch ppc64 -arch x86_64'
2. ./configure --with-apxs=/usr/sbin/apxs --with-python=/usr/local/bin
3. make
4. sudo make install
5. Add to /etc/apache2/httpd.conf
-> LoadModule wsgi_module libexec/apache2/mod_wsgi.so
6. tail -f /var/log/apache2/error_log
7. sudo apachectl stop
8. sudo apachectl start
Compile and Install MySQL
#################################################
NOTE: It has been said to also set CFLAGS="-arch i386 -arch ppc -arch ppc64 -arch x86_64"
NOTE: It has been said to also set CXXFLAGS="-arch i386 -arch ppc -arch ppc64 -arch x86_64"
1. export ARCHFLAGS='-arch ppc64'
2. CFLAGS="-arch ppc64' CXXLAGS="-arch ppc64' ./configure -prefix=/usr/local/mysql -with-server-suffix=-standard -enable-thread-safe-client -enable-local-infile -enable-shared -with-zlib-dir=bundled -with-big-tables -with-readline -with-plugins=all -without-docs
3. make
4. sudo make install
5. cd /usr/local/mysql
6. sudo ./bin/mysql_install_db --user=mysql
7. sudo chown -R mysql ./var
8. create file com.mysql.mysqld.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>com.mysql.mysqld</string>
<key>Program</key>
<string>/usr/local/mysql/bin/mysqld_safe</string>
<key>RunAtLoad</key>
<true/>
<key>UserName</key>
<string>mysql</string>
<key>WorkingDirectory</key>
<string>/usr/local/mysql</string>
</dict>
</plist>
9. sudo mv ~/Desktop/com.mysql.mysqld.plist /Library/LaunchDaemons
10. sudo chown root /Library/LaunchDaemons/com.mysql.mysqld.plist
11. sudo launchctl load -w /Library/LaunchDaemons/com.mysql.mysqld.plist
12. edit /etc/paths
-> /usr/local/mysql/bin
13. Quit all running terminals
14. run mysql_secure_installation
Compile and Install MySQLdb-Python
#################################################
NOTE: According to the compilation flags above it "should" be safe to leave Threadsafe at true
NOTE: setuptools must be installed prior to attempting the below
1. Set Threadsafe=False in site.cfg
2. export ARCHFLAGS='-arch i386 -arch ppc -arch ppc64 -arch x86_64'
3. python setup.py build
4. sudo python setup.py install
5. python-all <-Universal app, python is aliased to python32 so the next step will fail
6. import MySQLdb
7. hopefully no errors
0 comments
October 4, 2010 by Chris Barker
Django Deployment on Leopard PPC64 Research
See Step By Step HOWTO.txt
#################################################
Links that have proven useful
#################################################
http://tickletik.blogspot.com/2008/12/python-and-mysql-on-64bit.html <-Best all inclusive article
http://mysql-python.blogspot.com/2008/03/i-am-not-dead.html
http://mail.python.org/pipermail/pythonmac-sig/2008-June/020123.html
http://www.stereoplex.com/2008/feb/5/mac-os-x-command-and-manual-search-path-path-and-m/
http://www.softec.lu/site/DevelopersCorner/MasteringThePathHelper
http://code.google.com/p/modwsgi/wiki/QuickInstallationGuide
http://code.google.com/p/modwsgi/wiki/QuickConfigurationGuide
http://diymacserver.com/installing-mysql/compiling-mysql-51x-in-64-bits-mode-on-leopard/
http://mysql-python.sourceforge.net/FAQ.html
Native MacOSX Leopard Bit Levels
#################################################
-Native Python (2.51) 32Bit
-Native Apache (2.2.14) 64Bit
-Native MySQL (N/A)
Build Out Python 64bit
#################################################
To Perform Universal Compilation
Execute the below prior to compiling
export ARCHFLAGS='-arch i386 -arch ppc -arch ppc64 -arch x86_64'
./configure --with-framework-name=Python64 --with-universal-archs=all --enable-framework --enable-universalsdk=/ MACOSX_DEPLOYMENT_TARGET=10.5
Adjusting The Path
------------------
Add /usr/local/bin to the top of /etc/paths
Modify /etc/profile to:
if [ -x /usr/libexec/path_helper ]; then
PATH=""
eval '/usr/libexec/path_helper -s'
fi
Build Out MySQL 64Bit
#################################################
CFLAGS="-arch ppc64" <-Perhaps not needed if export ARCHFLAGS is set first
CXXFLAGS="-arch ppc64" <-Perhaps not needed if export ARCHFLAGS is set first
export ARCHFLAGS='-arch i386 -arch ppc -arch ppc64 -arch x86_64'
./configure -prefix=/usr/local/mysql -with-server-suffix=-standard -enable-thread-safe-client -enable-local-infile -enable-shared -with-zlib-dir=bundled -with-big-tables -with-readline -with-plugins=all -without-docs
make
sudo make install
Build Out MySQLdb
#################################################
Set Threadsafe=False in site.cfg
export ARCHFLAGS='-arch i386 -arch ppc -arch ppc64 -arch x86_64'
python setup.py build
sudo python setup.py install
Build Out Apache 64Bit ??? Or Not
#################################################
No need to rebuild apache, it is native universal binary (Runs in 64bit Navtively)
Vhost notes
-----------
<VirtualHost *:80>
ServerName www.example.com
ServerAlias example.com
ServerAdmin [email protected]
DocumentRoot /usr/local/www/documents
Alias /robots.txt /usr/local/www/documents/robots.txt
Alias /favicon.ico /usr/local/www/documents/favicon.ico
Alias /media/ /usr/local/www/documents/media/
<Directory /usr/local/www/documents>
Order allow,deny
Allow from all
</Directory>
WSGIPythonHome /Path/to/Python/
WSGIDaemonProcess example.com processes=2 threads=15 display-name=%{GROUP}
WSGIProcessGroup example.com
WSGIScriptAlias / /usr/local/www/wsgi-scripts/myapp.wsgi
<Directory /usr/local/www/wsgi-scripts>
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
HTTPD.conf notes
----------------
LoadModule wsgi_module libexec/apache2/mod_wsgi.so
Build Out mod_wsgi
#################################################
export ARCHFLAGS='-arch i386 -arch ppc -arch ppc64 -arch x86_64'
./configure --with-apxs=/usr/sbin/apxs --with-python/path/to/python
make
sudo make install
Cleaning Up After Compiling
#################################################
make clean
make distclean