0

I want to be able to create dynamic graphs within my Flask application. I am running this application within a virtual environment on a Linux box.

I looked around for different libraries that would help me with this, and identified Pygal as the one which I would like to use.

So, I activated my virtual environment using source venv/bin/activate and installed using pip install pygal. Everything installed correctly and I can import it perfectly in using the regular Python interface.

However, when I put import pygal into my Flask application and run the application, I get the following error in the logs.

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

Does anyone know how I can resolve this?

Many thanks.

-- EDIT --

RE: Sean Vieira

Results of adding from sys import path; print(path) to my run script:

*** 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)
LJPPython
  • 31
  • 2
  • 4

1 Answers1

0

Issue resolved.

I had to add the path to the package into the sys.path as described in an answer for this question. As I couldn't get Pygal to install within my virtual environment for some reason.

Community
  • 1
  • 1
LJPPython
  • 31
  • 2
  • 4