3

It's worth noting that I'm using a custom buildpack to enable coffeescript compilation with node.js.

After a change that included a migration, I got the below error upon running the migration

Running `./manage.py migrate talent` attached to terminal... up, run.3366
Traceback (most recent call last):
  File "./manage.py", line 8, in <module>
    from django.core.management import execute_from_command_line
  File "/app/lib/python2.7/site-packages/django/core/management/__init__.py", line 1, in <module>
    import collections
  File "/usr/local/lib/python2.7/collections.py", line 8, in <module>
    from _collections import deque, defaultdict
ImportError: No module named _collections

After poking around a bit in a heroku run bash shell session I found that the same error could be triggered by opening a python repl and running import collections.

0

1 Answer 1

2

Further poking revealed that the error could be suppressed by adding /usr/local/lib/python2.7/:/usr/local/lib/python2.7/lib-dynload/ to $PYTHONPATH. I first tried to to this in the bin/release file of the buildpack, but I also had a PYTHONPATH config variable which apparently overrides the buildpack setting of the environment (as it probably should).

Anyway fixing the $PYTHONPATH made everything work again, but this feels awkward, like a symptom that something else has gone wrong. Hopefully someone with more Heroku knowledge than me can shed some light.

1
  • I started having the same trouble when using Anaconda. I appended to my sys.path the lib-dynload, site-packages, python2.7 and lib that was located in my conda env.
    – zerocog
    Commented Aug 1, 2016 at 20:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.