部署leancloud失败,提示ImportError: No module named lxml.html,requirements.txt已包含gevent>=1.0.2,<2.0.0
lxml>3.4.4,<=3.5.1
html5lib>1.0b1,<=1.0b10
BeautifulSoup4>4.3.2,<=4.5.1
gevent-websocket>=0.9.5,<1.0.0
leancloud-sdk>=1.0.9,<=2.0.0
Werkzeug>=0.11.11,<1.0.0
Flask>=0.10.1,<1.0.0
Flask-Sockets>=0.1,<1.0
tushare>=0.5.6,<0.6.0
sqlalchemy>=1.0,<2.0
Configure>=0.3.5,<0.5

具体日志如下:
部署到:生产环境(web)
压缩项目文件 ...
生成临时文件:/var/folders/x6/p1dblf2d579b29qf8fdjm8cm0000gn/T/1480492302519.zip
开始上传项目文件 ...
2016-11-30 15:51:46 [INFO] 开始构建 20161130-155146
2016-11-30 15:51:46 [INFO] 正在下载应用代码 ...
2016-11-30 15:51:47 [INFO] 正在解压缩应用代码 ...
2016-11-30 15:51:47 [INFO] 运行环境: python (leanengine/python-base-2.7)
2016-11-30 15:51:47 [INFO] 正在下载和安装依赖项 ...
2016-11-30 15:51:54 [ERROR] 部署失败:The command '/bin/sh -c pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple && chown -R leanengine:leanengine .' returned a non-zero code: 1:
Requirement already satisfied (use --upgrade to upgrade): gevent<2.0.0,>=1.0.2 in /usr/local/lib/python2.7/dist-packages (from -r requirements.txt (line 1))
Collecting lxml<=3.5.1,>3.4.4 (from -r requirements.txt (line 2))
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/8b/be/ed850baac891aca25c832fb8d7b9c0e7a5077a30e336d95ffc7d649aaa06/lxml-3.5.0.tar.gz1 (3.8MB)
Collecting html5lib<=1.0b10,>1.0b1 (from -r requirements.txt (line 3))
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/2f/74/7793ca2d36f676b740efc04b7ba887c610119beb5841d1805cb3515616cb/html5lib-1.0b10-py2.py3-none-any.whl (112kB)
Collecting BeautifulSoup4<=4.5.1,>4.3.2 (from -r requirements.txt (line 4))
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/dc/27/8919b7a505b00f410c1c113c6c93b3253784375797976272e4198f4e455a/beautifulsoup4-4.5.1-py2-none-any.whl (83kB)
Requirement already satisfied (use --upgrade to upgrade): gevent-websocket<1.0.0,>=0.9.5 in /usr/local/lib/python2.7/dist-packages (from -r requirements.txt (line 5))
Collecting leancloud-sdk<=2.0.0,>=1.0.9 (from -r requirements.txt (line 6))
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/f9/8c/db2a1fbe7a00bcf20f6ec81fd275532079c19f7d5c9690ae9b2ec2fc5a90/leancloud-sdk-1.8.0.tar.gz
Collecting Werkzeug<1.0.0,>=0.11.11 (from -r requirements.txt (line 7))
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/a9/5e/41f791a3f380ec50f2c4c3ef1399d9ffce6b4fe9a7f305222f014cf4fe83/Werkzeug-0.11.11-py2.py3-none-any.whl (306kB)
Collecting Flask<1.0.0,>=0.10.1 (from -r requirements.txt (line 8))
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/63/2b/01f5ed23a78391f6e3e73075973da0ecb467c831376a0b09c0ec5afd7977/Flask-0.11.1-py2.py3-none-any.whl (80kB)
Collecting Flask-Sockets<1.0,>=0.1 (from -r requirements.txt (line 9))
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/62/a1/2295e41c32f591093cce519282ceeb6a968945bf497faa83a124e206aa26/Flask_Sockets-0.2.1-py2.py3-none-any.whl
Collecting tushare<0.6.0,>=0.5.6 (from -r requirements.txt (line 10))
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/01/ec/294c34ab8d9ef0d316a2c4e8ff03af8d7e5f6207ab84d602e848d2c08a37/tushare-0.5.9.zip (106kB)
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "", line 1, in
File "/tmp/pip-build-PEzh_M/tushare/setup.py", line 4, in
import tushare
File "/tmp/pip-build-PEzh_M/tushare/tushare/__init__.py", line 7, in
from tushare.stock.trading import (get_hist_data, get_tick_data,
File "/tmp/pip-build-PEzh_M/tushare/tushare/stock/trading.py", line 13, in
import lxml.html
ImportError: No module named lxml.html

----------------------------------------

Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-PEzh_M/tushare/
You are using pip version 8.1.2, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

求解决方法,谢谢!

你好,看上去像是 tushare 这个模块的问题,可以搜索一下有没有相关解决方法。

看报错信息是 tushare 依赖了一个并非你 requirements.txt 里指定的 lxml 的版本号。

我试过好多版本了,都不行,在本地都是可以的

会不会是因为pip的版本问题呢?

通过日志,发现是在 pip install 的这个过程中,tushare 就开始 import lxml 了,而这个时候 lxml 才下载,并没有被安装。

哦,谢谢,原来是这样啊,和本地工程不一样,有什么解决方案吗?

我看到了 tushare 的源码,发现他在 setup.py 里面就 import 自己了,然后它自己又会 import
所有依赖项,这样会导致上面的问题: https://github.com/waditu/tushare/blob/master/setup.py#L412

可以尝试 fork 一份 tushare 的代码,改掉 setup.py 里面的这部分。或者联系作者修改。

好,谢谢!