Rhilip/PT-help

部署后端,出现 Internal error

BFDZ opened this issue · 9 comments

BFDZ commented

用 fask 测试运行

snipaste_20181030_105532.jpg

api首页和301跳转都是正常的,获取电影信息时会出现错误 Internal error : None, please connect @Rhilip, thank you.
snipaste_20181030_105605.jpg

试过 uwsgi 也会报这个错误

我的数据库配置文件是复制默认的,没有启用数据库,貌似ptgen是不需要用到数据库的。我尝试配置数据库,又会出现 MYSQL_DATABASE_PASSWORD 未定义的错误

snipaste_20181030_105815.jpg

希望R酱能提供帮助,感谢!

请尝试在 modules/infogen 目录下运行

~/PT-help/modules/infogen$ python3 
Python 3.5.2 (default, Nov 23 2017, 16:37:01) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from gen import Gen
>>> g = Gen("https://movie.douban.com/subject/26972258/").gen(_debug=True)

并报告返回的异常信息。我个人这边调试该条豆瓣链接未发现这个问题。

BFDZ commented
root@host5-7-61-217:/home/wwwroot/xx/modules/infogen# python3
Python 3.6.3 (default, Oct 25 2018, 23:55:14) 
[GCC 4.7.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from gen import Gen
>>> g = Gen("https://movie.douban.com/subject/26972258/").gen(_debug)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name '_debug' is not defined
g = Gen("https://movie.douban.com/subject/26972258/").gen(_debug=True)

我的锅,没给对 后面加的是 _debug=True 。。。

BFDZ commented
Python 3.6.3 (default, Oct 25 2018, 23:55:14) 
[GCC 4.7.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from gen import Gen
>>> g = Gen("https://movie.douban.com/subject/26972258/").gen(_debug=True)
Traceback (most recent call last):
  File "/home/wwwroot/api.nas.ink/modules/infogen/gen.py", line 123, in gen
    getattr(self, "_gen_{}".format(self.site))()
  File "/home/wwwroot/api.nas.ink/modules/infogen/gen.py", line 135, in _gen_douban
    douban_page = get_page(douban_link, bs_=True)
  File "/home/wwwroot/api.nas.ink/modules/infogen/gen.py", line 81, in get_page
    return BeautifulSoup(page.text, "lxml")
  File "/usr/local/python3/lib/python3.6/site-packages/bs4/__init__.py", line 198, in __init__
    % ",".join(features))
bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library?

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/wwwroot/api.nas.ink/modules/infogen/gen.py", line 130, in gen
    raise Exception("Internal error").with_traceback(err.__traceback__)
  File "/home/wwwroot/api.nas.ink/modules/infogen/gen.py", line 123, in gen
    getattr(self, "_gen_{}".format(self.site))()
  File "/home/wwwroot/api.nas.ink/modules/infogen/gen.py", line 135, in _gen_douban
    douban_page = get_page(douban_link, bs_=True)
  File "/home/wwwroot/api.nas.ink/modules/infogen/gen.py", line 81, in get_page
    return BeautifulSoup(page.text, "lxml")
  File "/usr/local/python3/lib/python3.6/site-packages/bs4/__init__.py", line 198, in __init__
    % ",".join(features))
Exception: Internal error

@Rhilip

BFDZ commented

没装 lxml 导致的,requirement 里面没写这个

@BFDZ 通过uwsgi怎么服务doc里的静态文件?

@inevity 使用web服务器的路径管理(如nginx的location块的root或者alias)处理静态文件

@BFDZ 如果只要movieinfogen那部分,可以考虑自己把gen.py那个抽出来,拿flask或者其他python的web框架包一下就行。
不需要整个装,因为这个项目也是当初学flask时候瞎写的