时间:20220715
环境:Linux SuSE 12.3 python:2.7.13
操作流程:
1、安装系统所需基础包
zypper in python-setuptools gcc gcc-c++ rzsz
2、安装pip
理论可以使用easy_install,我这台电脑失败了(原因未知)
地址:
https://files.pythonhosted.org/packages/45/ae/8a0ad77defb7cc903f09e551d88b443304a9bd6e6f124e75c0fbbf6de8f7/pip-18.1.tar.gz
将文件上传至Linux,并解压,切换目录到解压目录,执行:
python setup.py install
安装成功!
3、安装python-devel(务必根据指定版本安装)
文件地址:
ftp://ftp.pbone.net/mirror/ftp5.gwdg.de/pub/opensuse/repositories/Cloud:/OpenStack:/Master/SLE_12_SP3/x86_64/python-devel-2.7.13-27.1.x86_64.rpm
下载后上传至Linux,并安装:
rpm -ivh python-devel-2.7.13-27.1.x86_64.rpm
4、安装paramiko 1.17.1,执行:
pip install paramiko==1.17.1
成功:
期间报错以及思路:
本来,计划最近两年可能不会再写博客,可是今天真生气,费了将近4个钟头吧!!!
在Linux安装paramiko有个重要的事情就是必须安装pycrypto模块,我下载源码安装(使用pip安装,报错相同),执行:
python setup.py install
报错如下:
src/MD2.c:31:20: fatal error: Python.h: No such file or directory
#include "Python.h"
^
compilation terminated.
error: command 'gcc' failed with exit status 1
经过神奇的操作,还有如下报错:
gcc: error: unrecognized command line option ‘-fstack-clash-protection’
查找到下面文章:https://blog.csdn.net/mingtiannihaoabc/article/details/103545564
它给我提出了思路,解决问题最根本的关键
我们都知道在Linux使用python,一般都有python-devel,可是SuSE本地源并没有该包,我将python相关的本地包看了很多次,就是没能发现有与python-devel相关的,该作者告诉我直接去网站找即可,不过最开始版本的问题(他说不关注依赖包将我误解了),我也没能成功。
我在rpm官网找到了和我匹配的python-devel的包,python-base如下:
linux-g56v:~/test/pycrypto-2.6.1 # rpm -qi python-base
Name : python-base
Version : 2.7.13
Release : 27.1
Architecture: x86_64
Install Date: Wed Feb 16 17:00:57 2022
Group : Development/Languages/Python
Size : 24112317
License : Python-2.0
Signature : RSA/SHA256, Tue Mar 7 10:08:27 2017, Key ID 70af9e8139db7c82
Source RPM : python-base-2.7.13-27.1.src.rpm
Build Date : Tue Mar 7 10:06:59 2017
Build Host : sheep15
Relocations : (not relocatable)
Packager : https://www.suse.com/
Vendor : SUSE LLC <https://www.suse.com/>
URL : http://www.python.org/
Summary : Python Interpreter base package
Description :
Python is an interpreted, object-oriented programming language, and is
often compared to Tcl, Perl, Scheme, or Java. You can find an overview
of Python in the documentation and tutorials included in the python-doc
(HTML) or python-doc-pdf (PDF) packages.
This package contains all of stand-alone Python files, minus binary
modules that would pull in extra dependencies.
Distribution: SUSE Linux Enterprise 12
我的python-devel:python-devel-2.7.13-27.1.x86_64.rpm
请注意两个包的版本对应,均为2.7.13-27.1,如果此处有差别,就可能报错(我第一次失败的原因)
结束----------------------------------------------------