在新服务器上安装python环境

安装python3.5可能使用的依赖

yum install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel

到python官网找到下载路径, 用wget下载

wget https://www.python.org/ftp/python/3.5.3/Python-3.5.3.tgz
wget https://www.python.org/ftp/python/3.6.3/Python-3.6.3.tgz

报错:

-bash:wget:command not found

Liunx系统中,-bash: wget: command not found是找不到命令的意思,也就是无法执行下载命令,主要是因为你的系统太干净了,没有安装下载命令的控制器,我们给系统安装个下载命令器即可。 
CentOS系统:

yum install wget -y

Debian/Ubuntu系统,需要执行以下命令:

apt-get install -y wget

解决办法:

yum install wget -y

再次执行

wget https://www.python.org/ftp/python/3.5.3/Python-3.5.3.tgz

解压tgz包

tar -zxvf Python-3.5.3.tgz

把python移到/usr/local下面

mv Python-3.5.3 /usr/local

删除旧版本的python依赖

ll /usr/bin | grep python
rm -rf /usr/bin/python

进入python目录

cd /usr/local/Python-3.5.3/

配置

./configure

报错:

yum install gcc

报错:

-bash: /usr/bin/yum: /usr/bin/python: bad interpreter: No such file or directory

报错原因时由于python的版本不匹配,只要在/usr/bin/yum中把第一行的#!/usr/bin/python改成

vim /usr/bin/yum  将文件中的python版本改为对应的即可

再次执行

yum install gcc

报错:

 查看依赖包的位置

yum provides '*/applydeltarpm'

yum -y  install deltarpm

yum clean cache
yum makecache

此时需执行:yum clean all  

重新链接下python

ln -s /usr/bin/python2.7 /usr/bin/python

然后运行命令

yum update 

输入

python 验证

配置

./configure

编译 make

make

编译,安装

make install

删除旧的软链接,创建新的软链接到最新的python

rm -rf /usr/bin/python
ln -s /usr/local/bin/python3.5 /usr/bin/python
python -V

回到 /root/

在进入

项目

执行

pip install -r requirements.txt

报错:

解决办法:

pip install --upgrade pip

再次执行

pip install -r requirements.txt

报错

sudo python3 -m pip install typing

还是报错:

pip3 install -r requirements.txt

pip3 install -i https://pypi.douban.com/simple/ -r requirements.txt
pip3 install -i https://pypi.douban.com/simple/ django==2.2.19

报错:

django.core.exceptions.ImproperlyConfigured: SQLite 3.8.3 or later is required (found 3.7.17).

这是因为centos 默认的版本为3.7.17,并没有更新,我们只需要安装新的SQLite代替老版本就可以了。可以去搜索sqlite官网去下载源码。

wget https://www.sqlite.org/2019/sqlite-autoconf-3280000.tar.gz
tar -zxvf sqlite-autoconf-3280000.tar.gz
cd sqlite-autoconf-3280000

./configure --prefix=/usr/local
make && make install
find /usr/ -name sqlite3

删除不必要的文件
rm -rf sqlite-autoconf-3280000*


mv /usr/bin/sqlite3  /usr/bin/sqlite3_old
ln -s /usr/local/bin/sqlite3   /usr/bin/sqlite3

vim ~/.bashrc
export LD_LIBRARY_PATH="/usr/local/lib"
source ~/.bashrc


[root@localhost bin]# python
Python 3.5.2 (default, Nov  5 2019, 17:15:00) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlite3
>>> sqlite3.sqlite_version
'3.28.0'

离线执行:

./configure --prefix=/usr/local

报错:

[root@localhost sqlite-autoconf-3280000]# ./configure --prefix=/usr/local
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking for style of include used by make... GNU
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/root/all_dependent_packages/sqlite-autoconf-3280000':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details
[root@localhost sqlite-autoconf-3280000]#

  • 9
    点赞
  • 25
    收藏
    觉得还不错? 一键收藏
  • 8
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 8
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值