`
tcspecial
  • 浏览: 896213 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

安装python2与python3

阅读更多

 

现在很多python模块不支持python2了,迁移至python3是大势所趋。

操作系统版本:

Linux 3.10.107

 

1. 安装python3.7.2

下载源码编译安装后,发现目录下未生成pip,手动安装:

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py

 

运行报错:

 

ModuleNotFoundError: No module named '_ctypes'

 

 

ctypes是python与c混合编程库,安装ffi 组件:

 

sudo yum install libffi-devel -y
make -j4
make install

 终于在$PYTHONDIR/bin下生成pip3。

 

 

2. 安装插件

 

$ pip3 install dicttoxml
Can't connect to HTTPS URL because the SSL module is not available

 

 

好像缺失openssl库,执行yum安装:

$ ./configure --prefix=/usr/local/python3 --with-ssl --enable-shared
$ make -j4 && make install
$ python3
>>> $ import ssl 
>>> ssl.__file__
'/usr/local/python3/lib/python3.6/ssl.py'

 ssl正常,但是仍然无法解决上述问题,初步怀疑python-3.7.2 的bug。

 

3. 回退python3.6.8

编译安装python-3.6.8,然后再编译后运行:

$ pip3 install dicttoxml

安装dicttoxml组件成功,看来最新版本不一定适于生产环境。

 

 4. 安装MySQLdb

yum install pip
yum install python-devel
pip install MySQL-python

 

 

 

 

 

 

 

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics