yum install python-virtualenv python-pip python-setuptools
/usr/bin/virtualenv -p /usr/local/bin/python2.7 /home/himalayas/virtualenv/python-2.7-configclient
source /home/himalayas/virtualenv/python-2.7-configclient/bin/activate----进入
在虚环境中进行如下操作:
单独安装:pip install python-cjson==1.0.5
批量安装:pip install -r /home/wuxy/fare_requirement.txt
# cat fare_requirement.txt
MySQL-python==1.2.4
SQLAlchemy==0.8.4
amqplib==1.0.2
configobj==4.7.2
hiredis==0.1.1
meld3==0.6.10
pika==0.9.13
python-cjson==1.0.5
redis==2.9.1
supervisor==3.0
tornado==2.4.1
wsgiref==0.1.2
xlrd==0.9.2
xlutils==1.7.0
xlwt==0.7.5
如果有提示如下:
The required version of distribute (>=0.6.28) is not available,
and can‘t be installed while this script is running. Please
install a more recent version first, using
‘easy_install -U distribute‘.
则按提示执行easy_install -U distribute
然后执行:pip install -r /home/wuxy/fare_requirement.txt
可以执行pip freeze查看是否全部安装成功。
安装成功后,在虚环境中启动程序,命令如下:
/home/himalayas/virtualenv/python-2.7-configclient/bin/python -O /home/himalayas/configpushclient/cpclient/cpclientd.py -port=** -processnumber=4 -log_level=info -log_path=/home/nginxlog/kxlog/configpushclient/cpclient -logging=info
注意:** 换成对应的端口
在主环境中执行:
python -O /home/himalayas/configpushclient/cpclient/cpclientd.py -port=** -processnumber=4 -log_level=info -log_path=/home/nginxlog/kxlog/configpushclient/cpclient -logging=info
报错提示:ImportError: No module named cjson
这种报错一种原因是没有安装cjson,另一种原因是安装了,但是没有安装在这个版本的python环境中,所以这个版本的python找不到cjson包。
[[email protected] wuxy]# pip freeze | grep json
python-cjson==1.0.5
[[email protected] site-packages]# find /usr/ -name *json*
/usr/lib64/python2.6/json
/usr/lib64/python2.6/site-packages/cjson.so
/usr/lib64/python2.6/site-packages/python_cjson-1.0.5-py2.6.egg-info
/usr/lib64/python2.6/lib-dynload/_json.so
解决方法:
python2.6 -O /home/himalayas/configpushclient/cpclient/cpclientd.py -port=** -processnumber=4 -log_level=info -log_path=/home/nginxlog/kxlog/configpushclient/cpclient -logging=info
注意:** 换成对应的端口
或者在主环境中安装相应的包!