virtualenv 依赖项对 Ubuntu 18.04 的响应不佳

virtualenv dependencies don't respond well to Ubuntu 18.04

我正在两台计算机上构建这个项目,windows 10 和 ubuntu 18.04。实际上我从来没有成功地完全使用 ubuntu 电脑。每当我尝试向数据库发出 post 请求时,我都会收到此错误:

    File "/home/user/venv1/lib/python3.6/site-packages/flask/app.py", line 1985, in wsgi_app
    response = self.handle_exception(e)
  File "/home/user/venv1/lib/python3.6/site-packages/flask_cors/extension.py", line 161, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
  File "/home/user/venv1/lib/python3.6/site-packages/flask/app.py", line 1540, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/home/user/venv1/lib/python3.6/site-packages/flask/_compat.py", line 33, in reraise
    raise value
  File "/home/user/venv1/lib/python3.6/site-packages/flask/app.py", line 1982, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/user/venv1/lib/python3.6/site-packages/flask/app.py", line 1614, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/user/venv1/lib/python3.6/site-packages/flask_cors/extension.py", line 161, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
  File "/home/user/venv1/lib/python3.6/site-packages/flask/app.py", line 1517, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/home/user/venv1/lib/python3.6/site-packages/flask/_compat.py", line 33, in reraise
    raise value
  File "/home/user/venv1/lib/python3.6/site-packages/flask/app.py", line 1612, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/user/venv1/lib/python3.6/site-packages/flask/app.py", line 1598, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/home/user/venv1/lib/python3.6/site-packages/flask/views.py", line 84, in view
    return self.dispatch_request(*args, **kwargs)
  File "/home/user/venv1/lib/python3.6/site-packages/flask/views.py", line 149, in dispatch_request
    return meth(*args, **kwargs)
  File "/home/user/venv1/lib/python3.6/site-packages/flask_apispec/annotations.py", line 117, in wrapped
    return wrapper(*args, **kwargs)
  File "/home/user/venv1/lib/python3.6/site-packages/flask_apispec/wrapper.py", line 29, in __call__
    response = self.call_view(*args, **kwargs)
  File "/home/user/venv1/lib/python3.6/site-packages/flask_apispec/wrapper.py", line 48, in call_view
    return self.func(*args, **kwargs)
  File "/home/user/venv1/lib/python3.6/site-packages/flask_security/decorators.py", line 216, in decorated_view
    return fn(*args, **kwargs)
//project related methods which work flawlessly
  File "/home/user/venv1/lib/python3.6/site-packages/flask_sqlalchemy/__init__.py", line 417, in get_or_404
    rv = self.get(ident)
  File "/home/user/venv1/lib/python3.6/site-packages/sqlalchemy/orm/query.py", line 882, in get
    ident, loading.load_on_ident)
  File "/home/user/venv1/lib/python3.6/site-packages/sqlalchemy/orm/query.py", line 893, in _get_impl
    if len(ident) != len(mapper.primary_key):
TypeError: object of type 'NoneType' has no len()

不过我试过了:

  1. pip freeze 在 windows virtualenv 上,这就是我得到 "good" 版本,尝试用相同的方式配置 ubuntu 的 venv 但错误不断出现
  2. 我尝试在 setup.py 文件中不指定依赖项版本,但我得到了完全相同的错误。

我在应用程序中使用的 mysql 用户已获得数据库的所有权限。 我正在使用版本 14.14 Distrib 5.7.23,用于 Linux (x86_64)。 由于我是使用 Ubuntu 18.04 的新手,我需要以某种方式设置我的 mysql 吗?

我已经安装了 mysql 8,现在工作正常。