在python2.7中安装cos-ftp-server出现的一些常见问题,记录下避免再次出现同样的问题
基于系统版本:Centos7.5.1804,Python版本2.7.5做测试。
安装步骤
安装必要环境
如文档所述,使用pip安装以下几个模块
cos-python-sdk-v5(≥1.6.5)
pyftpdlib(≥1.5.2)
psutil(>=5.6.1)
pipinstallpsutil
pipinstallpyftpdlib
pipinstallcos-python-sdk-v5
如果提示nocommand,则要安装python-pip
yuminstallpython-pip-y
开始正式安装
项目地址:https://github.com/tencentyun/cos-ftp-server-V5
安装git(选)
下载项目可以忽略git,直接在github中下载包同样可行
如果有兴趣可以找下怎么安装git2.x,yum版本为1.18,但不影响使用
yuminstall-ygit
下载项目
gitclonehttps://github.com/tencentyun/cos-ftp-server-V5.git
安装运行
cdcos-ftp-server-V5
pythonsetup.pyinstall
到此基本安装完了,后续可以再回到文档中配置。配置没问题即可使用了。
安装提醒报错
提醒'extras_require'mustbeadictionary
ERROR:Commanderroredoutwithexitstatus1:
command:/usr/bin/python2-c'importsys,setuptools,tokenize;sys.argv[0]='"'"'/tmp/pip-install-vwGRKd/psutil/setup.py'"'"';__file__='"'"'/tmp/pip-install-vwGRKd/psutil/setup.py'"'"';f=getattr(tokenize,'"'"'open'"'"',open)(__file__);code=f.read().replace('"'"'\r\n'"'"','"'"'\n'"'"');f.close();exec(compile(code,__file__,'"'"'exec'"'"'))'egg_info--egg-base/tmp/pip-pip-egg-info-mLL9IK
cwd:/tmp/pip-install-vwGRKd/psutil/
Completeoutput(5lines):
/usr/lib64/python2.7/distutils/dist.py:267:UserWarning:Unknowndistributionoption:'python_requires'
warnings.warn(msg)
/usr/lib64/python2.7/distutils/dist.py:267:UserWarning:Unknowndistributionoption:'long_description_content_type'
warnings.warn(msg)
errorinpsutilsetupcommand:'extras_require'mustbeadictionarywhosevaluesarestringsorlistsofstringscontainingvalidproject/versionrequirementspecifiers.
----------------------------------------
ERROR:Commanderroredoutwithexitstatus1:pythonsetup.pyegg_infoCheckthelogsforfullcommandoutput.
初步判断是与pip自带的setuptools版本安装存在冲突
pipinstall-Upip
pipinstall-Urequests
pipinstall-Usetuptools
提醒gcc未安装
gcc-pthread-fno-strict-aliasing-O2-g-pipe-Wall-Wp,-D_FORTIFY_SOURCE=2-fexceptions-fstack-protector-strong--param=ssp-buffer-size=4-grecord-gcc-switches-m64-mtune=generic-D_GNU_SOURCE-fPIC-fwrapv-DNDEBUG-O2-g-pipe-Wall-Wp,-D_FORTIFY_SOURCE=2-fexceptions-fstack-protector-strong--param=ssp-buffer-size=4-grecord-gcc-switches-m64-mtune=generic-D_GNU_SOURCE-fPIC-fwrapv-fPIC-DPSUTIL_POSIX=1-DPSUTIL_SIZEOF_PID_T=4-DPSUTIL_VERSION=573-DPSUTIL_LINUX=1-I/usr/include/python2.7-cpsutil/_psutil_common.c-obuild/temp.linux-x86_64-2.7/psutil/_psutil_common.o
psutil/_psutil_common.c:9:20:fatalerror:Python.h:Nosuchfileordirectory
#include<Python.h>
^
compilationterminated.
error:command'gcc'failedwithexitstatus1
----------------------------------------
ERROR:Commanderroredoutwithexitstatus1:/usr/bin/python2-u-c'importsys,setuptools,tokenize;sys.argv[0]='"'"'/tmp/pip-install-VCi9XS/psutil/setup.py'"'"';__file__='"'"'/tmp/pip-install-VCi9XS/psutil/setup.py'"'"';f=getattr(tokenize,'"'"'open'"'"',open)(__file__);code=f.read().replace('"'"'\r\n'"'"','"'"'\n'"'"');f.close();exec(compile(code,__file__,'"'"'exec'"'"'))'install--record/tmp/pip-record-A1ljvJ/install-record.txt--single-version-externally-managed--compile--install-headers/usr/include/python2.7/psutilCheckthelogsforfullcommandoutput.
安装python-devel
yuminstallpython-devel
其他-查看模块版本
方法1.引入模块并进行查看
>>>importrequests
>>>requests.__version__
'2.9.0'
方法2.使用help(模块名查看),在最后几行可以看到
>>>help(requests)
···
···
VERSION
2.9.0
AUTHOR
KennethReitz
方法3.使用piplist查看
[root@VM-1-16-centos~]#piplist|greprequests
requests(2.6.0)
原文链接:https://cloud.tencent.com/developer/article/1754186