问题描述:

I've made a very simple Twitter bot in Python using the Tweepy library. Everything works beautifully locally and it tweets when I run the correct script exactly as it's supposed to. However, I'd like to automate this so that it tweets a couple of times a day, so have tried using the Heroku Scheduler for this.

I'm able to push to Heroku with no problems, but when I try to run the worker on Heroku I get this error message (which means of course the scheduler isn't working either since it's running the same process):

 Running `worker` attached to terminal... up, run.8157

/app/.bash_profile: line 6: parts: command not found

Traceback (most recent call last):

File "/app/workspace/botlovesyou/lovescript.py", line 4, in <module>

import tweepy, time

ImportError: No module named tweepy

So, erm...what now? I've Googled and found this but am not sure how to actually fix it. This question looks deceptively similar but I don't have the other missing dependency that caused his issue.

I've tried running pip install tweepy again but of course it says 'Requirement already satisfied'. I've tried pip uninstalling it then pip installing it again - it reinstalls no problem, but I get the same error when it's on heroku. I've also tried installing the buildpack mentioned at the link above but it failed to build and wouldn't allow me to push so I removed it.

EDIT: I've now also tried git cloning and installing tweepy using setup.py. Again, installation ran with no errors but Heroku still says there's no module named Tweepy.

Tweepy is definitely installed in the site-packages directory. What am I missing?

Many thanks.

网友答案:

Problem resolved (this problem, anyway).

Install was aborting when it reached PIL in the requirements.txt file - it can't be installed via pip and was just skipping installing everything after it. I don't require PIL for this project so just removed it from requirements (I don't really know why it was in requirements in the first place, I think it was a nitrous.io preinstall). Very simple solution in this case.

Edited to add - on starting a new Python box on Nitrous, PIL was preinstalled correctly. So I think my initial install might have been corrupted.

Ugh. Edited again. Nitrous seems to have eaten PIL again, or maybe Heroku has. Same error. Again removed it from requirements.

相关阅读:
Top