Forums

Import error in scheduled file

Hi, a script that have to be scheduled uses RoboBrowser which is installed in virtualenv. So, I put '#!/usr/bin/env python3.3' hash-bang on the top of the file. When I run it the following exception is raised:

Traceback (most recent call last):                                                                                                                                              
  File "/home/gestionebeb/bebwebsite/bebapp/schedule.py", line 7, in <module>                                                                                                   
    from robobrowser import RoboBrowser                                                                                                                                         
ImportError: No module named 'robobrowser'

Here are the first lines of code:

1
2
3
4
5
6
7
8
#!/usr/bin/env python3.3

import re
import time
from datetime import datetime, timedelta
from bs4 import BeautifulSoup
from robobrowser import RoboBrowser
......

Where is the problem? Thanks

Does this help:

https://www.pythonanywhere.com/forums/topic/1447/

?

You're not actually using your virtualenv in that script. That link jgmdavies gave has details about how to make sure your task uses your virtualenv.