janeczku / calibre-web

:books: Web app for browsing, reading and downloading eBooks stored in a Calibre database
GNU General Public License v3.0
13.07k stars 1.39k forks source link

Python2.7 - Tornado webserver SyntaxError: invalid syntax #993

Closed OzzieIsaacs closed 5 years ago

OzzieIsaacs commented 5 years ago

Hi, I'm getting a similar message when trying to run cps.py for the first time after installation. root@Plugins:/usr/local/calibre-web # python2.7 cps.py No handlers could be found for logger "cps.services" Traceback (most recent call last): File "cps.py", line 34, in from cps import create_app File "/usr/local/calibre-web/cps/init.py", line 38, in from .server import WebServer File "/usr/local/calibre-web/cps/server.py", line 33, in from tornado.wsgi import WSGIContainer File "/usr/local/calibre-web/vendor/tornado/wsgi.py", line 51 def to_wsgi_str(s: bytes) -> str: ^ SyntaxError: invalid syntax

Originally posted by @muken in https://github.com/janeczku/calibre-web/issues/987#issuecomment-516659419

OzzieIsaacs commented 5 years ago

The first message has nothing to say. Your problem is totally different from the one in the original post. For a reason whatsoever you have a problem with the "tornado" dependency. Which python version are you using? Could you please try to delete the tornado folder in the vendor folder and try to reinstall it?

muken commented 5 years ago

I have Python 3.6 and 2.7, and pip 3.6 and 2.7. Think it's defaulting to 3.6 but I'm trying to run cps.py with python2.7. I tried deleting the tornado folder from the vendor folder and reinstalled but I'm seeing the same message.

OzzieIsaacs commented 5 years ago

The error is in one of the dependencies. I've doublechecked it this morning, for me it was working (even with the newest version tornado 6.0.3). The package at pyi states a minimum version of python 3.5. grafik Python2 will reach end of life on 31.12.2019. Looks like it's no longer supported from "tornado".

You could try:

If you run with python 3.6 it's working?

OzzieIsaacs commented 5 years ago

Okay, Ifound the statement that python2 is no longer supported: grafik

muken commented 5 years ago

I tried again with python3.6 and got this message:

root@Plugins:/usr/local/calibre-web # python3.6 cps.py goodreads: No module named 'goodreads' simpleldap: No module named 'flask_simpleldap' Traceback (most recent call last): File "/usr/local/lib/python3.6/site-packages/sqlalchemy/dialects/sqlite/pysqlite.py", line 338, in dbapi from pysqlite2 import dbapi2 as sqlite ModuleNotFoundError: No module named 'pysqlite2'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "cps.py", line 34, in from cps import create_app File "/usr/local/calibre-web/cps/init.py", line 66, in ub.init_db(cli.settingspath) File "/usr/local/calibre-web/cps/ub.py", line 473, in init_db engine = create_engine(u'sqlite:///{0}'.format(app_db_path), echo=False) File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/init.py", line 435, in create_engine return strategy.create(args, kwargs) File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/strategies.py", line 87, in create dbapi = dialect_cls.dbapi(dbapi_args) File "/usr/local/lib/python3.6/site-packages/sqlalchemy/dialects/sqlite/pysqlite.py", line 343, in dbapi raise e File "/usr/local/lib/python3.6/site-packages/sqlalchemy/dialects/sqlite/pysqlite.py", line 341, in dbapi from sqlite3 import dbapi2 as sqlite # try 2.5+ stdlib name. File "/usr/local/lib/python3.6/sqlite3/init.py", line 23, in from sqlite3.dbapi2 import File "/usr/local/lib/python3.6/sqlite3/dbapi2.py", line 27, in from _sqlite3 import * ModuleNotFoundError: No module named '_sqlite3' root@Plugins:/usr/local/calibre-web #

OzzieIsaacs commented 5 years ago

We are getting closer. There are some parts of sqlalchemy missing. You could try to: reinstall sqlalchemy, or the internet suggests to do "apt-get install libsqlite3-dev" (depending on your distro, maybe different). A pip3 freeze shows these two sqlalchemy libs for me:

SQLAlchemy==1.3.4 SQLAlchemy-Utils==0.34.1

How did you install the dependencys? What distro (version) are you using? Is this a "normal PC" or a NAS, Raspi or something else?

muken commented 5 years ago

Almost see the light! This is for FreeNAS 11.2. I used pip install --target vendor -r requirements.txt to install dependencies.

pip3 freeze shows : SQLAlchemy==1.3.6 sqlite3==0.0.0 tornado==6.0.3

I installed py36-sqlite3, tried again and got: root@Plugins:/usr/local/calibre-web # python3.6 cps.py goodreads: No module named 'goodreads' simpleldap: No module named 'flask_simpleldap'

OzzieIsaacs commented 5 years ago

Perfect than you are done, it's working. Just go to the site: http://???:8083 and you should see the config page. I will change the 2 messages to debug, because it look like it confuses a lot of people.

muken commented 5 years ago

Awesome, I'm in thanks so much!