Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
tgorup opened this issue Feb 21, 2014 · 5 comments
Closed

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

tgorup opened this issue Feb 21, 2014 · 5 comments

Comments

@tgorup
Copy link

tgorup commented Feb 21, 2014

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
Copy link
Author

tgorup commented Feb 21, 2014

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
Copy link
Owner

@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
Copy link
Author

tgorup commented Feb 27, 2014

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
Copy link

jarv commented Jun 16, 2014

@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
Copy link
Owner

closing; this appears to be an environment-specific error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants