1、问题:服务代码需要python2.6运行,安装的扩展需要python2.7以上
解决:指定版本安装
pip install SQLAlchemy==1.0.9 -i http://pypi.douban.com/simple --trusted-host pypi.douban.com
import sqlalchemy print sqlalchemy.__version__
常用pip源:
阿里云 http://mirrors.aliyun.com/pypi/simple/ 豆瓣(douban) http://pypi.douban.com/simple/ 清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/ 中国科学技术大学 http://pypi.mirrors.ustc.edu.cn/simple/
2、Tornado 错误 “Global name ‘memoryview’ is not defined”
解决:
pip uninstall tornado pip install tornado==2.1.1
3、mac python2.7安装pip报错:
Installing collected packages: pip WARNING: The scripts pip, pip2 and pip2.7 are installed in '/Users/yongmenggan/Library/Python/2.7/bin' which is not on PATH. Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
解决:
echo 'export PATH=/Users/yongmenggan/Library/Python/2.7/bin:$PATH' >>~/.bashrc source ~/.bashrc
4、pip安装zeroc-ice报错:
src/ice/cpp/src/Ice/ConnectionI.cpp:27:21: 致命错误:.....
解决:
原因是缺失相关依赖包 mcpp、bzip2、expat等
安装相关依赖包:
yum install lmdb-devel mcpp-devel yum install bzip2-devel yum install expat-devel
如果提示没有相关包,可以执行以下命令:
yum -y install epel-release yum update
Python 字符串反转义:
str1 = r"teststr" # 加r反转义 str2 = "teststr" #被转义
python3 UnicodeEncodeError: ‘gbk’ codec can’t encode character ‘\xxx’
print输出乱码:
sys.stdout = io.TextIOWrapper(sys.stdout.buffer,encoding='utf8')
安装Crypto
from Crypto.Cipher import AES
pip3 install Crypto pip3 install pycryptodome
找到site-packages目录,将crypto改成Crypto
D:\www\python3\Lib\site-packages
python2.7.5安装pip:
cd /usr/local/src/ # 安装setuptools wget https://files.pythonhosted.org/packages/b5/96/af1686ea8c1e503f4a81223d4a3410e7587fd52df03083de24161d0df7d4/setuptools-46.1.3.zip unzip setuptools-46.1.3.zip cd setuptools-46.1.3 python setup.py install # 安装pip wget https://files.pythonhosted.org/packages/d1/05/059c78cd5d740d2299266ffa15514dad6692d4694df571bf168e2cdd98fb/pip-20.1.tar.gz tar -zxvf pip-20.1.tar.gz cd pip-20.1/ python setup.py install
python2.7 安装pip插件时,提示setuptools版本过高:
************************************************************ You are running Setuptools on Python 2, which is no longer supported and >>> SETUPTOOLS WILL STOP WORKING <<< in a subsequent release (no sooner than 2020-04-20). Please ensure you are installing Setuptools using pip 9.x or later or pin to `setuptools<45` in your environment. If you have done those things and are still encountering this message, please follow up at https://bit.ly/setuptools-py2-warning. ************************************************************
降级解决:
pip install --user "setuptools<45"
转载请注明:永盟博客 » python问题解决汇总