Flask Pygal安装 - 没有名为pygal的模块

时间:2014-02-24 19:45:43

标签: python flask virtualenv pygal

我希望能够在Flask应用程序中创建动态图形。我在Linux机器上的虚拟环境中运行此应用程序。

我四处寻找可以帮助我解决此问题的不同库,并将Pygal确定为我想要使用的库。

因此,我使用source venv/bin/activate激活了我的虚拟环境,并使用pip install pygal进行了安装。所有东西都安装正确,我可以使用常规的Python界面完美地导入它。

但是,当我将import pygal放入Flask应用程序并运行应用程序时,我在日志中收到以下错误。

Traceback (most recent call last):
    File "/usr/share/nginx/www/mydir/run.py", line 2, in <module>
        from app import app
    File "/usr/share/nginx/www/mydir/app/__init__.py", line 23, in <module>
        from app import views, models
    File "/usr/share/nginx/www/mydir/views.py", line 9, in <module>
        import datetime, locale, pygal
    ImportError: No module named pygal

有谁知道如何解决这个问题?

非常感谢。

- 编辑 -

RE:Sean Vieira

from sys import path; print(path)添加到我的运行脚本的结果:

*** Starting uWSGI 1.9.20 (32bit) on [Tue Feb 25 14:55:16 2014] ***
compiled with version: 4.6.3 on 04 December 2013 05:11:40
os: Linux-3.8.0-29-generic #42~precise1-Ubuntu SMP Wed Aug 14 15:31:16 UTC 2013
nodename: **hidden**
machine: i686
clock source: unix
detected number of CPU cores: 1
current working directory: /etc/uwsgi/vassals
detected binary path: /usr/share/nginx/www/mydir/venv/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
your processes number limit is 3840
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to UNIX address /usr/share/nginx/www/mydir/mydir_uwsgi.sock fd 3
Python version: 2.7.3 (default, Sep 26 2013, 20:26:19)  [GCC 4.6.3]
Set PythonHome to /usr/share/nginx/www/mydir/venv
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0x93e80a8
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 169864 bytes (165 KB) for 1 cores
*** Operational MODE: single process ***
added /usr/share/nginx/www/mydir/ to pythonpath.
['/usr/share/nginx/www/mydir/', '.', '',      '/usr/share/nginx/www/mydir/venv/lib/python2.7/site-packages/distribute-0.6.24-py2.7.egg', '/usr/share/nginx/www/mydir/venv/lib/python2.7/site-packages/pip-1.1-py2.7.egg', '/usr/share/nginx/www/mydir/venv/lib/python2.7', '/usr/share/nginx/www/mydir/venv/lib/python2.7/plat-linux2', '/usr/share/nginx/www/mydir/venv/lib/python2.7/lib-tk', '/usr/share/nginx/www/mydir/venv/lib/python2.7/lib-old', '/usr/share/nginx/www/mydir/venv/lib/python2.7/lib-dynload', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-linux2', '/usr/lib/python2.7/lib-tk', '/usr/share/nginx/www/mydir/venv/lib/python2.7/site-packages']
WSGI app 0 (mountpoint='') ready in 1 seconds on interpreter 0x93e80a8 pid: 20964     (default app)
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 20964)
spawned uWSGI worker 1 (pid: 20981, cores: 1)

1 个答案:

答案 0 :(得分:0)

问题已解决。

我必须将包的路径添加到sys.path中,如this question的答案中所述。因为某些原因我无法让Pygal安装在我的虚拟环境中。