windows安装fdfs_lient报错”fdfs_client/sendfilemodule: fatal error C1189: #error: platfom not supported”
报错详情(报错内容:windows这个平台不支持fdfs_client)
running install running bdist_egg running egg_info writing fdfs_client_py.egg-info\PKG-INFO writing dependency_links to fdfs_client_py.egg-info\dependency_links.txt writing top-level names to fdfs_client_py.egg-info\top_level.txt reading manifest file 'fdfs_client_py.egg-info\SOURCES.txt' reading manifest template 'MANIFEST.in' warning: no files found matching 'fdfs_client\client.conf' writing manifest file 'fdfs_client_py.egg-info\SOURCES.txt' installing library code to build\bdist.win-amd64\egg running install_lib running build_py running build_ext building 'fdfs_client.sendfile' extension C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Ie:\anaconda3\include -Ie:\anaconda3\include "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\8.1\include\shared" "-IC:\Program Files (x86)\Windows Kits\8.1\include\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\winrt" /Tcfdfs_client/sendfilemodule.c /Fobuild\temp.win-amd64-3.6\Release\fdfs_client/sendfilemodule.obj sendfilemodule.c fdfs_client/sendfilemodule.c(53): fatal error C1189: #error: platfom not supported error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\cl.exe' failed with exit status 2
pip install mutagen pip isntall requests
修改fdfs_client/storage_client.py文件,将第12行删除或注释(否则,使用时会报错ImportError: No module named sendfile)
# from fdfs_client.sendfile import * 将改行注释或者删除
然后创建client.conf文件,我所创建的路径为“F:\Projects\django_env”。
client.conf文件中将以下代码复制及进去,修改并保存,修改tracker_server=127.0.0.1:22122这行,将‘127.0.0.1’修改成你自己的服务器地址(22122端口需要自己在阿里云上配置安全规则),还需要修改‘base_path=F:\Projects\django_env’,base_path修改成你自己的path。
# connect timeout in seconds # default value is 30s connect_timeout=30 # network timeout in seconds # default value is 30s network_timeout=60 # the base path to store log files base_path=F:\Projects\django_env # tracker_server can ocur more than once, and tracker_server format is # "host:port", host can be hostname or ip address tracker_server=127.0.0.1:22122 #standard log level as syslog, case insensitive, value list: emerg for emergency alert crit for critical error warn for warning notice info debug log_level=info # if use connection pool # default value is false # since V4.05 use_connection_pool = false # connections whose the idle time exceeds this time will be closed # unit: second # default value is 3600 # since V4.05 connection_pool_max_idle_time = 3600 # if load FastDFS parameters from tracker server # since V4.05 # default value is false load_fdfs_parameters_from_tracker=false # if use storage ID instead of IP address # same as tracker.conf # valid only when load_fdfs_parameters_from_tracker is false # default value is false # since V4.05 use_storage_id = false # specify storage ids filename, can use relative or absolute path # same as tracker.conf # valid only when load_fdfs_parameters_from_tracker is false # since V4.05 storage_ids_filename = storage_ids.conf #HTTP settings http.tracker_server_port=80 #use "#include" directive to include HTTP other settiongs include http.conf
测试代码:
from fdfs_client.client import Fdfs_client client = Fdfs_client('F:/Projects/django_env/client.conf') ret = client.upload_by_filename('timg.jpg') print(ret)
输出控制台
F:\Projects\django_env\Scripts\python.exe F:/Projects/axf/fastdfs_demo/test.py getting connection <fdfs_client.connection.Connection object at 0x00000BE0> <fdfs_client.fdfs_protol.Tracker_header object at 0x00000BA8> {
'Group name': 'group1', 'Remote file_id': 'group1\\M00/00/00/rBBx9lxQEX2AO4peAANB4Pemyig458.jpg', 'Status': 'Upload successed.', 'Local file name': 'timg.jpg', 'Uploaded size': '208.00KB', 'Storage IP': '47.98.173.29'} Process finished with exit code 0
OK,能正常使用了。
发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/177076.html原文链接:https://javaforall.net
