Forums

Module not being detected although it is installed

Hi,

I'm trying to run a script on PythonAnywhere but it's throwing an exception saying a module isn't installed but I think I have installed it:

I installed it via pip: http://i.imgur.com/s94LgNo.png Tried using pip2.7 as well It says it has been installed

This is the start of my script:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
#!/usr/bin/python2.7

from trello import TrelloApi
from pprint import pprint
import ast
from openpyxl import load_workbook
import os
import ftplib
from twilio.rest import TwilioRestClient
from Pastebin import PastebinAPI
from time import sleep

I thought maybe it was starting it with the wrong version of python so I added the hashbang "#!/usr/bin/env python2.7" as described on https://www.pythonanywhere.com/wiki/SaveAndRunPythonVersion but it said there was no such interpreter so I added #!/usr/bin/python2.7 instead and now this is the error I get:

Traceback (most recent call last):
  File "/home/lukei2w/bot.py", line 11, in <module>
    from Pastebin import PastebinAPI
ImportError: No module named Pastebin

I get the feeling I'm just doing something really obvious wrong, if someone could point that out for me I'd be really grateful.

Any help is appreciated, thanks in advance :)

Here's a couple of things to try:

  • open up a Python 2.7 console and type "import Pastebin" - does it work?
  • at the top of your script, add a couple of debug lines

.

import sys
print(sys.version)
print(sys.path)

Thanks for the reply! :)

Opening a Python 2.7 console and typing import Pastebin does not work

This is what I get from the debug lines:

2.7.6 (default, Jun 22 2015, 17:58:13) 
[GCC 4.8.2]
['/home/lukei2w/', '/home/lukei2w/.local/lib/python2.7/site-packages', '/usr/local/lib/python2.7/dist-packages/snappy-2
.3.2-py2.7-linux-x86_64.egg', '/usr/local/lib/python2.7/dist-packages/cypari-1.2.2-py2.7-linux-x86_64.egg', '/usr/local/lib/python2.7/dist-packages/
pypng-0.0.18-py2.7.egg', '/usr/local/lib/python2.7/dist-packages/FXrays-1.3.1-py2.7-linux-x86_64.egg', '/usr/local/lib/python2.7/dist-packages/spher
ogram-1.4.1-py2.7-linux-x86_64.egg', '/usr/local/lib/python2.7/dist-packages/plink-1.8-py2.7.egg', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-x8
6_64-linux-gnu', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-package
s', '/usr/local/lib/python2.7/dist-packages/Orange/orng', '/usr/local/lib/python2.7/dist-packages/PIL', '/usr/lib/python2.7/dist-packages', '/usr/li
b/pymodules/python2.7', '/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode']

Ah. it should be "import pastebin" with a lowercase p according to the docs?

https://pypi.python.org/pypi/Pastebin/1.1.1

That's strange, the code runs fine on my local machine

I tried with a lower case p and still had the same issue

I had a little play around with it myself, I can confirm I see the problem too.

It looks like it's a bug in the latest version of pastebin: https://github.com/Morrolan/PastebinAPI/issues/1, but the bug doesn't occur on windows. Perhaps that's why your own machine works fine?

In any case, you can try reverting back to a previous version of pastebin, that seems to work for me:

pip install --user pastebin==1.1.0

That worked! Thanks so much for your help. :)

how did you install openpyxl?

On my bash it gives error because of it is previous version

I tried to add it on myself this time it gives some python syntax error because of version difference

Please help.

what is the exact command that you tried to run, and what is the exact error (with the full stacktrace)?