没有名为sqlalchemy的模块

时间:2018-01-02 04:31:04

标签: python sqlalchemy flask-sqlalchemy

我尝试过使用sudo easy_install sqlalchemy,pip install sqlalchemy和pip install flask-sqlalchemy。我也尝试过安装和卸载sqlalchemy和flask。我收到了错误

Traceback (most recent call last):
  File "/usr/lib/python2.7/multiprocessing/process.py", line 267, in _bootstrap
    self.run()
  File "/usr/lib/python2.7/multiprocessing/process.py", line 114, in run
    self._target(*self._args, **self._kwargs)
  File "/home/j/Downloads/ng-website-master/venv/local/lib/python2.7/site-packages/hupper/worker.py", line 264, in worker_main
    func(*spec_args, **spec_kwargs)
  File "/home/j/Downloads/ng-website-master/venv/local/lib/python2.7/site-packages/pyramid/scripts/pserve.py", line 40, in main
    return command.run()
  File "/home/j/Downloads/ng-website-master/venv/local/lib/python2.7/site-packages/pyramid/scripts/pserve.py", line 222, in run
    app_spec, name=app_name, relative_to=base, global_conf=vars)
  File "/home/j/Downloads/ng-website-master/venv/local/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 247, in loadapp
    return loadobj(APP, uri, name=name, **kw)
  File "/home/j/Downloads/ng-website-master/venv/local/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 272, in loadobj
    return context.create()
  File "/home/j/Downloads/ng-website-master/venv/local/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 710, in create
    return self.object_type.invoke(self)
  File "/home/j/Downloads/ng-website-master/venv/local/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 146, in invoke
    return fix_call(context.object, context.global_conf, **context.local_conf)
  File "/home/j/Downloads/ng-website-master/venv/local/lib/python2.7/site-packages/paste/deploy/util.py", line 55, in fix_call
    val = callable(*args, **kw)
  File "/home/j/Downloads/ng-website-master/ngse/__init__.py", line 15, in main
    config.include('.models')
  File "/home/j/Downloads/ng-website-master/venv/local/lib/python2.7/site-packages/pyramid/config/__init__.py", line 776, in include
    c = self.maybe_dotted(callable)
  File "/home/j/Downloads/ng-website-master/venv/local/lib/python2.7/site-packages/pyramid/config/__init__.py", line 876, in maybe_dotted
    return self.name_resolver.maybe_resolve(dotted)
  File "/home/j/Downloads/ng-website-master/venv/local/lib/python2.7/site-packages/pyramid/path.py", line 320, in maybe_resolve
    return self._resolve(dotted, package)
  File "/home/j/Downloads/ng-website-master/venv/local/lib/python2.7/site-packages/pyramid/path.py", line 327, in _resolve
    return self._zope_dottedname_style(dotted, package)
  File "/home/j/Downloads/ng-website-master/venv/local/lib/python2.7/site-packages/pyramid/path.py", line 382, in _zope_dottedname_style
    __import__(used)
  File "/home/j/Downloads/ng-website-master/ngse/models/__init__.py", line 4, in <module>
    import zope.sqlalchemy
ImportError: No module named sqlalchemy

即使在尝试升级sqlalchemy之后,我也得到了上述错误。

Requirement already up-to-date: sqlalchemy in ./venv/lib/python2.7/site-packages

尝试升级flask-sqlalchemy,仍然得到相同的错误

Requirement already up-to-date: flask-sqlalchemy in ./venv/lib/python2.7/site-packages
Requirement already up-to-date: SQLAlchemy>=0.8.0 in ./venv/lib/python2.7/site-packages (from flask-sqlalchemy)
Requirement already up-to-date: Flask>=0.10 in ./venv/lib/python2.7/site-packages (from flask-sqlalchemy)
Requirement already up-to-date: itsdangerous>=0.21 in ./venv/lib/python2.7/site-packages (from Flask>=0.10->flask-sqlalchemy)
Requirement already up-to-date: Jinja2>=2.4 in ./venv/lib/python2.7/site-packages (from Flask>=0.10->flask-sqlalchemy)
Requirement already up-to-date: Werkzeug>=0.7 in ./venv/lib/python2.7/site-packages (from Flask>=0.10->flask-sqlalchemy)
Requirement already up-to-date: click>=2.0 in ./venv/lib/python2.7/site-packages (from Flask>=0.10->flask-sqlalchemy)
Requirement already up-to-date: MarkupSafe>=0.23 in ./venv/lib/python2.7/site-packages (from Jinja2>=2.4->Flask>=0.10->flask-sqlalchemy)

我正在尝试在virtualenv中安装sqlalchemy。我还有python = 2.7.14,pip = 9.0.1,setuptools = 38.2.5和假定安装的sqlalchemy = 1.2.0 。我用过假设,因为当我尝试升级并检查sqlalchemy和flask-sqlalchemy的版本时,我的计算机显示它已安装但我无法使用它。

这是我打印出sys.path

时得到的结果
['', '/usr/lib/python2.7', 
'/usr/lib/python2.7/plat-x86_64-linux-gnu', 
'/usr/lib/python2.7/lib-tk', 
'/usr/lib/python2.7/lib-old',
 '/usr/lib/python2.7/lib-dynload', 
'/home/j/.local/lib/python2.7/site-packages', '/usr/local/lib/python2.7/dist-packages', 
'/usr/local/lib/python2.7/dist-packages/MySQL_python-1.2.5-py2.7-linux-x86_64.egg', 
'/usr/local/lib/python2.7/dist-packages/SQLAlchemy-1.2.0-py2.7-linux-x86_64.egg', 
'/usr/lib/python2.7/dist-packages']

请帮帮我。我不知道还能做什么

2 个答案:

答案 0 :(得分:0)

您的pip安装错误。

将sqalchemy更改为sqlalchemy,因此它是:

pip install sqlalchemy

并确保在激活的virtualenv中这样做。

答案 1 :(得分:0)

我得到了和你一样的错误。 我解决了它:

  1. 我删除了我的virtrualenv,并创建了一个新的

  2. 运行pip3 install -r requirment.text安装sudo pip3 install -r requirment.text(如果上面的命令获得权限拒绝错误,则应运行sudo chown -R user /usr/local/lib/python3.6/