kurttheviking / simple-hipchat-py

Python client fo HipChat's v1 API
Other
85 stars 25 forks source link

AttributeError: 'module' object has no attribute 'HipChat' #10

Closed tgorup closed 10 years ago

tgorup commented 10 years ago

I'm not sure what I'm doing wrong exactly. Possibly I'm doing my initial import/install wrong? Running the follow script:

import hipchat

hipster = hipchat.HipChat(token='APIKEY')   # For notification only

hipster.method('rooms/message', method='POST', parameters={'room_id': 'IDNUM', 'from': 'ThisBot', 'message': 'My Message', 'notify': '1', 'color': 'red'} )

I receive the following error:

$ python2.6 tt.py
Traceback (most recent call last):
  File "tt.py", line 5, in <module>
    hipster = hipchat.HipChat(token='APITOKENT')    # For notification only
AttributeError: 'module' object has no attribute 'HipChat'

And

$ python tt.py
Traceback (most recent call last):
  File "tt.py", line 5, in <module>
    hipster = hipchat.HipChat(token='APITOKENHERE') # For notification only
AttributeError: 'module' object has no attribute 'HipChat'

I'm running this on CentOS:

$ uname -r
2.6.32-431.5.1.el6.x86_64

Tried pip install:

$ pip install python-simple-hipchat
Downloading/unpacking python-simple-hipchat
  Downloading python-simple-hipchat-0.2.tar.gz
  Running setup.py (path:/tmp/pip_build_root/python-simple-hipchat/setup.py) egg_info for package python-simple-hipchat
Installing collected packages: python-simple-hipchat
  Running setup.py install for python-simple-hipchat
Successfully installed python-simple-hipchat
Cleaning up...

Also tried installing from git:

$ python setup.py install
running install
running build
running build_py
creating build
creating build/lib
creating build/lib/hipchat
copying hipchat/__init__.py -> build/lib/hipchat
running install_lib
copying build/lib/hipchat/__init__.py -> /usr/lib/python2.6/site-packages/hipchat
byte-compiling /usr/lib/python2.6/site-packages/hipchat/__init__.py to __init__.pyc
running install_egg_info
removing '/usr/lib/python2.6/site-packages/python_simple_hipchat-0.2-py2.6.egg-info' (and everything under it)
Writing /usr/lib/python2.6/site-packages/python_simple_hipchat-0.2-py2.6.egg-info
$ pip freeze
hipchat==0.0.1
httplib2==0.8
pycurl==7.19.0
pygpgme==0.1
python-simple-hipchat==0.2

Had my initial testing running perfectly on OSx. Please let me know if you need any other info.

tgorup commented 10 years ago

Was running python2.6, thought that may have been the issue. Did an altmake for Python2.7, forced pip to install to 2.7's site-packages, and I'm still getting the above error.

kurttheviking commented 10 years ago

@tgorup curious; i've not seen that error before. my first guess is that there's a permissions issue somewhere in the deployed environment -- especially since it seems to work on your local machine. can you try sudo pip install on the target machine (or is this restricted to a virtual env?).

tgorup commented 10 years ago

I tried the sudo pip install and it says it's already installed. Also tried using --ignore-installed. Still doesn't appear to be working. I think you might be right that it's a permissions issue. But I'm unfortunately not seeing where it could be. I attempted all of this as root. What's odd is it isn't breaking on the import, but rather on the execution.

$ sudo pip install python-simple-hipchat
Requirement already satisfied (use --upgrade to upgrade): python-simple-hipchat in /usr/lib/python2.6/site-packages
Cleaning up...
$ sudo pip install --ignore-installed python-simple-hipchat
Downloading/unpacking python-simple-hipchat
  Downloading python-simple-hipchat-0.2.tar.gz
#!/usr/bin/python
  Running setup.py (path:/tmp/pip_build_root/python-simple-hipchat/setup.py) egg_info for package python-simple-hipchat
Installing collected packages: python-simple-hipchat
  Running setup.py install for python-simple-hipchat
    Removing /usr/lib/python2.6/site-packages/python_simple_hipchat-0.2-py2.6.egg-info
Successfully installed python-simple-hipchat
Cleaning up...
$ ./t.py Testing
Traceback (most recent call last):
  File "./t.py", line 9, in <module>
    hipster = hipchat.HipChat(token='APITOKENHERE') # For notification only
AttributeError: 'module' object has no attribute 'HipChat'

t.py code:

#!/usr/bin/python

import hipchat
import sys
import ast

messageinput = sys.argv[1]  # Take message

hipster = hipchat.HipChat(token='APIKEYHERE')   # For notification only

# Post to Room
hipster.method('rooms/message', method='POST', parameters={'room_id': 'ROOMNUM', 'from': 'userBot', 'message': '%s' % (messageinput), 'notify': '0', 'color': 'green'} )
jarv commented 10 years ago

@tgorup it sounds like you might have a conflicting module with the same name. Do you have a python file in the same directory as t.py named hipchat.py? Or try this:

import hipchat
print hipchat.__file__

to make sure you are loading the right thing.

kurttheviking commented 10 years ago

closing; this appears to be an environment-specific error