Python import error in local environment only

I have an application that deploys to heroku and runs from Python 2.7.6. On my local machine, in the same Python version, I get an import error for the module where the launcher is located:

(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

      

In the pybossa folder there is an __ init__.py with this content:

__version__ = "0.1"

      

+3


source to share


2 answers


As Dan Cornilescu said, the problem is in the local environment. This was present when I was setting requirements from within the project (i.e. Run $ pip install -r requirements.txt

from the pybossa project).



When launched from the parent project, the environment was fine (i.e. $ pip install -r pybossa/requirements.txt

)

+1


source


You probably have a mismatch in the environment in the two executions.

You can set to add the parent of the pybossa directory to your PYTHONPATH (just an example, but it is better to try to match environments, otherwise other surprises may be hiding):



$~/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>

      

+2


source







All Articles