V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
lixuda
V2EX  ›  Python

Python ftp 上传 阿里云服务器问题

  •  
  •   lixuda · 2017-10-17 17:37:07 +08:00 · 2240 次点击
    这是一个创建于 2375 天前的主题,其中的信息可能已经有所发展或是发生改变。

    用 python ftplib 上传文件。本地运行程序一直正常。

    然后把代码放到阿里云运行,出现错误,应该是上传的时候返回的 ip 变成阿里云内网的 ip 地址,这个怎么解决?

    提示错误: ftplib.error_perm: 500 I won't open a connection to 阿里云内网 ip (only to 阿里云外网 ip)

    2 条回复    2017-10-20 14:17:10 +08:00
    dayinfinte
        1
    dayinfinte  
       2017-10-18 21:39:00 +08:00
    这个应该是跟 ftp 原理有关,并且你如果只是一个虚拟机,就没有公网 IP 的话,就不行,或者申请阿里云独享 IP 的服务,应该就可以了
    lixuda
        2
    lixuda  
    OP
       2017-10-20 14:17:10 +08:00
    @dayinfinte 解决了,不是虚拟机。ftplib 库会获取本机 ip 地址,然后获取的是内网的 ip,所以错误。我修改了库,指定外网 ip 就可以了。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5332 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 01:32 · PVG 09:32 · LAX 18:32 · JFK 21:32
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.