0

I am trying to install the fbchat module for Python on Ubuntu 22.04. The install seems to have been succesful, but whenever i try to launch a script with the module in it, i get the following error: ImportError: cannot import name 'fbchat' from 'fbchat' (/home/atlas/.local/lib/python3.10/site-packages/fbchat/init.py)

Before i installed, i updated my system, i am using Python v. 3.10.6 and pip v. 22.0.2. I have tried both the pip install, pip3 install, git-cloning and tarball installation methods, but the error keeps repeating. I am unable to find others with the same error, so i hope someone can provide me some clarity as to why this happens, and hopefully a fix.

Atlas
  • 11
  • 3
  • you might want to take a look of this https://stackoverflow.com/a/16377297/1781986 – Paul Wang Sep 29 '22 at 17:56
  • How are you importing it? Please provide the import statement used in the script. – Michael Ruth Sep 29 '22 at 17:57
  • Ive tried both "import fbchat" and "from fbchat import fbchat", the result is the same. – Atlas Sep 29 '22 at 18:00
  • how do you install fbchat? "sudo pip install" or just "pip install"? – Paul Wang Sep 29 '22 at 18:04
  • Tried both, also looked at the thread you posted and used chmod 777 /usr/local/lib/python3.10/site-packages. Problem sadly still persists. – Atlas Sep 29 '22 at 18:11
  • did you say "sudo chmod 777" or just "chmod 777"? if you just say "chmod 777" it won't work, assuming your directory is only root +rw permission. Plus, it seems the package you import from is not from /usr/local/lib/python3.10/site-packages but /home/atlas/.local/lib/python3.10/site-packages/fbchat – Paul Wang Sep 29 '22 at 18:17
  • Paul Wang, i figured it out thanks to your guidance. Thank you so much! – Atlas Sep 29 '22 at 18:19
  • As an addendum to this question: does anyone know if the module is still working? I'm getting login errors, and as far as i can read, the module is no longed updated and possibly patched out by Facebook themselves. – Atlas Sep 29 '22 at 18:44
  • I would recommend you post a new question for your "addendum". – Paul Wang Sep 29 '22 at 20:37

1 Answers1

0

If you install fbchat using

sudo pip install fbchat

then the package might somehow installed with root rw permission only, other user just cannot rw to it!

you might need to change your package permission to add +rx to user or group, for example, in your case:

sudo chmod -R ugo+rX /home/atlas/.local/lib/python3.10/site-packages/fbchat/

or

sudo chmod -R ugo+rX /home/atlas/.local/lib/python3.10/site-packages/
Paul Wang
  • 1,666
  • 1
  • 12
  • 19