install python262
#######################install python_2.6.2
./configure --prefix=/usr/local/python262
make
make install
mv /usr/local/bin/python /usr/local/bin/python.bak
ln -s /usr/local/python262/bin/python /usr/local/bin/python
########################install easy_install
wget http://peak.telecommunity.com/dist/ez_setup.py
python ez_setup.py
执行两次
会自动根据本机的py版本选择对应的egg
安装时提示找不到zlib
安装zlib
yast -i zlib
wget ftp://mirror.switch.ch/pool/1/mirror/scientificlinux/5rolling/x86_64/SL/zlib-devel-1.2.3-3.x86_64.rpm
yast -i zlib-devel-1.2.3-3.x86_64.rpm
再重新python ez_setup.py
设置环境变量
vim /etc/profile
export PATH=/usr/local/python262/bin:$PATH
source /etc/profile
安装完可以看到有/usr/bin/easy_install程序了
###########################################
easy_install MySQL-python
import MySQLdb
报错:
ImportError: libmysqlclient_r.so.16: cannot open shared object file: No such file or directory
1.确定libmysqlclient_r.so.16的位置
/usr/local/mysql/lib/mysql/libmysqlclient_r.so.16 -> libmysqlclient_r.so.16.0.0
2.确定libmysqlclient_r.so.16使用的函数库及其位置
ldd /usr/local/mysql/lib/mysql/libmysqlclient_r.so.16
/usr/local/mysql/lib/mysql/libmysqlclient_r.so.16.0.0
ldd -v /usr/local/mysql/lib/mysql/libmysqlclient_r.so.16
/lib64
3.拷贝函数库到需要位置
cp -af /usr/local/mysql/lib/mysql/libmysqlclient_r.so.16.0.0 /lib64 或者 vim /etc/ld.so.conf将/usr/local/mysql/lib/mysql该目录添加到第一行
4.ldconfig
5.ldconfig -v | grep libmysqlclient_r.so.16
import MySQLdb sucess!!!!
############################################
EnvironmentError: mysql_config not found
reason: can not find this file /usr/local/mysql/bin/mysql_config
solution:
vim /etc/profile
export PATH=/usr/local/mysql/bin/:$PATH
. /etc/profile
#####################################
#######miss module
Late last year, I set out to get some python apps running on mydreamhostaccount, previously I maintained this stuff on an ec2 ubuntu instance, so I could do whatever I wanted there. But ec2 is expensive and dreamhost is cheap, so I made the move.
Update May 15, 2010: Thanks toTommaso Lanza, who, has written ashell scriptto automate this installation, which now includes mercurial, he has also left afew notes in the comments. Use at your own risk!.
Python
I thought all I would need to do is compile Python and getvirtualenvrunning, but there was a little more to it, because as soon as I compiled Python I received the following warning:
Failed to find the necessary bits to build these modules: _bsddb _tkinter bsddb185 bz2 readline sunaudiodev To find the necessary bits, look in setup.py in detect_modules() for the module's name.
This doesn’t mean it didn’t compile, but it means those modules were not compiled in. I really wanted readline, and thought it would be a good idea to have bz2. I didn’t expect I’d need _tkinter, but who knows and I wasn’t sure when and where I might need berkeley db (_bsddb, note: you’ll need a 4.5 version of Berkeley DB if you want support). So I set out to compile these modules in. I wasn’t worried about needing sunaudiodev or bsddb185, they’re both very old.
Without documenting my errors along the way, here is how I installed Python 2.6.4 ondreamhost:
First give yourself a place to install the necessary packages, and then a place to compile them. You can name them whatever you want, I used$HOME/opt
to install and$HOME/tmp
to compile in.Dreamhost recommends$HOME/run
to install and$HOME/soft
to compile in. Do whatever your comfortable with.
$ cd ~ $ mkdir opt tmp
Grab everything you’ll need and put that in tmp:
$ cd tmp $ wget http://www.bzip.org/1.0.5/bzip2-1.0.5.tar.gz $ tar -xzf bzip2-1.0.5.tar.gz $ wget ftp://ftp.gnu.org/gnu/readline/readline-5.2.tar.gz $ tar -xzf readline-5.2.tar.gz $ wget http://prdownloads.sourceforge.net/tcl/tcl8.5.8-src.tar.gz $ tar -xzf tcl8.5.8-src.tar.gz $ wget http://prdownloads.sourceforge.net/tcl/tk8.5.8-src.tar.gz $ tar -xzf tk8.5.8-src.tar.gz $ wget http://python.org/ftp/python/2.6.4/Python-2.6.4.tgz $ tar -xzf Python-2.6.4.tgz $ wget http://download.oracle.com/berkeley-db/db-4.5.20.tar.gz $ tar -xzf db-4.5.20.tar.gz
Setup your environment:
$ export LD_LIBRARY_PATH=$HOME/opt/local/lib:$HOME/opt/local/BerkeleyDB.4.5/lib $ export LD_RUN_PATH=$LD_LIBRARY_PATH $ export LDFLAGS="-L$HOME/opt/local/lib -L$HOME/opt/local/BerkeleyDB.4.5/lib" $ export CPPFLAGS="-I$HOME/opt/local/include -I$HOME/opt/local/BerkeleyDB.4.5/include" $ export CXXFLAGS=$CPPFLAGS $ export CFLAGS=$CPPFLAGS
Setting all these environment variables may not be necessary it’s what I had at the end of compiling, Python looks atLDFLAGS
andCPPFLAGS
, the others are pretty standard compile env variables.
Update: Thanks toChristian, who,in the comments, provided additional instructionsto grab and install SSL support, if you think you’ll need SSL, here are the steps:
$ wget http://www.openssl.org/source/openssl-0.9.8m.tar.gz $ tar -xzf openssl-0.9.8m.tar.gz $ cd openssl-0.9.8m $ ./config --prefix=$HOME/opt/local --openssldir=$HOME/opt/local/openssl shared $ make $ make install $ cd ..
Compile and Install
$ cd readline-5.2 $ ./configure --prefix=$HOME/opt/local $ make $ make install $ cd .. $ cd tcl8.5.8/unix $ ./configure --prefix=$HOME/opt/local $ make $ make install $ cd ../.. $ cd tk8.5.8/unix $ ./configure --prefix=$HOME/opt/local $ make $ make install $ cd ../.. $ cd db-4.5.20/build_unix $ ../dist/configure \ > --prefix=$HOME/opt/local/BerkeleyDB.4.5 \ > --enable-tcl \ > --with-tcl=$HOME/opt/local/lib $ make $ make install $ cd ../.. $ cd bzip2-1.0.5 $ make $ make install PREFIX=$HOME/opt/local $ cd .. $ cd Python-2.6.4 $ ./configure --prefix=$HOME/opt/Python-2.6.4 $ make $ make install
When you ran make on Python-2.6.4, the only warning should now be:
Failed to find the necessary bits to build these modules: bsddb185 sunaudiodev To find the necessary bits, look in setup.py in detect_modules() for the module's name.
As I mentioned above, I don’t think I’ll ever need these 2 modules, if i ever do, I’ll worry about it then.
Next I updated my PATH to include the new binaries
$ cd ~ $ vi ~/.bashrc export PATH="$HOME/opt/local/bin:$PATH" $ source ~/.bashrc
virtualenv and virtualenvwrapper
And finally I installed virtualenv andvirtualenvwrapperalong with some things in my .bashrc to make life easier.
$ cd ~/tmp $ wget http://pypi.python.org/packages/source/v/virtualenv/virtualenv-1.4.3.tar.gz $ tar -xzf virtualenv-1.4.3.tar.gz $ ~/opt/Python-2.6.4/bin/python2.6 virtualenv-1.4.3/virtualenv.py $HOME/opt/local New python executable in /home/dawatts/opt/local/bin/python2.6 Also creating executable in /home/dawatts/opt/local/bin/python Installing setuptools............done. $ easy_install virtualenv $ cd .. $ wget http://www.doughellmann.com/downloads/virtualenvwrapper-1.23.tar.gz $ tar -xzf virtualenvwrapper-1.23.tar.gz $ mkdir $HOME/bin $ cp virtualenvwrapper-1.23/virtualenvwrapper_bashrc ~/bin/ $ cd ~ $ mdkir $HOME/.virtualenvs $ vi ~/.bashrc export WORKON_HOME=$HOME/.virtualenvs source $HOME/bin/virtualenvwrapper_bashrc $ source ~/.bashrc $ workon * $ mkvirtualenv testenv Using real prefix '/home/dawatts/opt/Python-2.6.4' New python executable in testenv/bin/python2.6 Also creating executable in testenv/bin/python Installing setuptools............done. (testenv)$ workon testenv (testenv)$ deactivate $ rmvirtualenv testenv
And there you have it, a Python 2.6.4/virtualenv environment setup on dreamhost to do whatever you wa