Traceback (most recent call last):
File "D:/pyprojects/qiniu/demo.py", line 26, in <module>
ret, info = put_file(token, key, localfile)
File "D:\Python\python34\lib\site-packages\qiniu\services\storage\uploader.py", line 64, in put_file
ret, info = _form_put(up_token, key, input_stream, params, mime_type, crc, progress_handler, file_name)
File "D:\Python\python34\lib\site-packages\qiniu\services\storage\uploader.py", line 80, in _form_put
url = config.get_default('default_zone').get_up_host_by_token(up_token) + '/'
File "D:\Python\python34\lib\site-packages\qiniu\zone.py", line 30, in get_up_host_by_token
up_hosts = self.get_up_host(ak, bucket)
File "D:\Python\python34\lib\site-packages\qiniu\zone.py", line 49, in get_up_host
bucket_hosts = self.get_bucket_hosts(ak, bucket)
File "D:\Python\python34\lib\site-packages\qiniu\zone.py", line 71, in get_bucket_hosts
bucket_hosts = self.get_bucket_hosts_to_cache(key)
File "D:\Python\python34\lib\site-packages\qiniu\zone.py", line 91, in get_bucket_hosts_to_cache
self.host_cache_from_file()
File "D:\Python\python34\lib\site-packages\qiniu\zone.py", line 107, in host_cache_from_file
path = self.host_cache_file_path()
File "D:\Python\python34\lib\site-packages\qiniu\zone.py", line 124, in host_cache_file_path
return home + "/.qiniu_pythonsdk_hostscache.json"
TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'
我用官方在github上得代码,我看源码是HOME环境变量没设置,这个怎么破?
我用的py3.4
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
在自己环境里面也试了一下:
Windows10 64Bits
Python3.5.2
也会报这个问题,再手动添加一个环境变量HOME之后,此问题得到解决:
另外在Linux环境下也分别试了:
Python2.7.8和Python3.5.2
均未出现此问题。
Root Cause还是环境变量的问题:
在我的环境里,默认情况下:
Linux
Windows环境下没有设置HOME环境变量