altdesktop / i3ipc-python

🐍 An improved Python library to control i3wm and sway.
http://i3ipc-python.readthedocs.io
BSD 3-Clause "New" or "Revised" License
851 stars 109 forks source link

module 'i3ipc' has no attribute 'Connection' #114

Closed prankousky closed 5 years ago

prankousky commented 5 years ago

Hi,

I just tried to learn i3ipc a bit. I downloaded it from PyPi and copied the example apps-on-ws-init.py. My version is Python 3.7.3 on an up-to-date Archlinux.

When I run the script, I get

Traceback (most recent call last):
  File "./app-on-ws-init.py", line 6, in <module>
    import i3ipc
  File "/home/me/test/i3ipc.py", line 7, in <module>
    i3 = i3ipc.Connection()
AttributeError: module 'i3ipc' has no attribute 'Connection'

I am just beginning to learn python, so I don't exactly know what this means... considering that this is an official example file, the attribute Connection should work. Is my python setup messed up or what could cause this?

Thanks for your support :)

acrisci commented 5 years ago

When you say import i3ipc, it's importing the file in that directory /home/me/test/i3ipc.py, not the library.

Rename that file and it should work.

Read this:

https://docs.python.org/3/tutorial/modules.html#the-module-search-path

prankousky commented 5 years ago

Doh! How could I not have thought of that. Thank you so much, works perfectly now.