在服务器上 运行Django 项目,报错解决方案

1,No module named ‘_ctypes’
File "/usr/local/python3/lib/python3.7/ctypes/__init__.py", line 7, in <module>    from _ctypes import Union, Structure, Array ModuleNotFoundError: No module named '_ctypes'

原因 Python3 有个内置包 ctypes 是一个 哇哦不函数库模块,提供兼容C语言的数据类型,通过调用Linux系统下的共享库,此模块需要使用CentOS7系统中外部函数库的开发练级库

解决方案

简单安装 外部函数库 libffi 就可以,操作步骤如下

1,使用 yum install 安装 libffi-level

    yum install libffi-devel -y

2,在 python 中 使用 make & make install重新编译并安装 python

make & make install

3, 最后测试即可;

参考文章:https://www.jianshu.com/p/69681655309b


2,no module named _ssl

缺少 ssl 包

centos 重新安装,再重新编译

yum install openssl-devel -y

修改 安装包\Modules\Setup中 以下内容

# Socket module helper for socket(2)
_socket socketmodule.c timemodule.c
# Socket module helper for SSL support; you must comment out the other
# socket line above, and possibly edit the SSL variable:
#SSL=/usr/local/ssl
_ssl _ssl.c \
-DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
-L$(SSL)/lib -lssl -lcrypto

重新编译

make && make install

测试

[root@iZbp1iyr83m78fp8yjv65xZ Python-3.7.6]# python3
Python 3.7.6 (default, Apr  2 2022, 22:15:08) 
[GCC 10.2.1 20200825 (Alibaba 10.2.1-3 2.32)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ssl
>>> exit()
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

程序员大飞1

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值