Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python import error on local environment only

I have an application which is deployed on heroku and runs, with Python 2.7.6 . On the local machine, the same Python version, I get import error for the module where is located the launcher:

(VIRTUALENV)$ python pybossa/web.py
Traceback (most recent call last):
  File "pybossa/web.py", line 31, in <module>
    import pybossa
ImportError: No module named pybossa

The pybossa folder has __ init__.py with this content:

__version__ = "0.1"
like image 853
ftraian Avatar asked May 17 '26 16:05

ftraian


1 Answers

You likely have a mismatch in the environment in the 2 execution cases.

You could set add the parent of the pybossa dir to your PYTHONPATH (just an example, but it's better to try to match the environments, other surprises can lurk in there otherwise):

$~/tmp> python pybossa/web.py
Traceback (most recent call last):
  File "pybossa/web.py", line 1, in <module>
    import pybossa
ImportError: No module named pybossa
$~/tmp> echo $PYTHONPATH
PYTHONPATH: Undefined variable.
$~/tmp> setenv PYTHONPATH '.'
$~/tmp> python pybossa/web.py
$~/tmp>
like image 108
Dan Cornilescu Avatar answered May 19 '26 07:05

Dan Cornilescu



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!