No module named 'fbchat' - python

So im new at python and programming and trying to work out the basic of fbchat which seems very manageable but I keep getting this error: ModuleNotFoundError: No module named 'fbchat' I'm 100% sure that I've installed fbchat by using:
pip install fbchat
and have also tried
git clone https://github.com/carpedm20/fbchat.git
pip install fbchat
Either way I still get the same error.
This is the code:
import fbchat
session = fbchat.Session.login("<xxxxxx#hotmail.com>", "<xxxx>")
print("Own id: {}".format(session.user.id))
session.user.send_text("Hi You!")
session.logout()
I really hope that you can help me with this problem, thank you for your time

First check your pip version is using desired python or not
pip --version
If not then you should use different pip version for an example if you're using python3 then install using pip3
If there's no issue of version then try to use virtual environment
create one using
python -m venv venv
source venv/bin/activate
pip install fbchat
Refer this link for os wise instructions
https://packaging.python.org/guides/installing-using-pip-and-virtual-environments/
Install using Python3.8 -m pip install fbchat

Related

No Module named 'fastapi' - Ubuntu environment

Though I have pip and pip3 installed fastapi library in my Ubuntu based workstation, I get a weird error saying
No module named 'fastapi'.
I have been scratching my head since two days ago as the same code works in other laptop with same Ubuntu environment.
Uninstalled and reinstalled fastapi library
you're not using the correct environment to run your code.
Either, 1. install the package fast-api in the environment you running the code in or 2. switch to the other one the packages are installed in:
for 1:
sudo /bin/python3 -m pip install "fastapi[all]"
in this case you should be able to use the fast-api package
Note: the other packages you use are probably not installed as well
Maybe you are using the wrong env? It looks like you're using vscode so you can specify the interpeter
Try pip install --upgrade pip and then pip install fastapi again
Try using conda, and do conda install -c conda-forge fastapi

Python - Notion API - Can't import module

I'm trying to use Notion API for some automation processes but I am having some trouble importing the packages and I already try a lot of imports. I've this code:
from notion_database.database import Database
my_token = "my_token"
D = Database(integrations_token=my_token )
print(D.list_databases(page_size=100))
To run this code I made the following imports:
pip install notion-database
pip install notion-py
pip install "notion==0.0.25"
pip install notion
All of them were installed correctly and I don't have my script name as "notion.py" :D
But when I run my code I got:
from notion_database.database import Database
ModuleNotFoundError: No module named 'notion_database'
Does anyone know what I am doing wrong?
Thanks for the help!
It looks your code is fine.
More likely, your python and pip points onto two different python versions.
I would suggest you create an environment (virtualenv or pyenv) and reinstall the packages using this command:
sudo python -m pip install notion-database
sudo python -m pip install notion-py
sudo python -m pip install "notion==0.0.25"
sudo python -m pip install notion
maybe you have not install notion successfully.
try to replace pip install notion
to pip install notion --user
,after that maybe there is no error with run "import notion".
good luck!

Why is a package I have installed not getting recognised

I have installed a package named hypixel for my discord bot using pip install hypixel. It finished installing without any errors. At the top of my script I have import hypixel. But when I try and run it I get this error:
File "D:\Documents\Discord Bot\Addicts Discord Bot\bot.py", line 1, in <module>
import hypixel
ModuleNotFoundError: No module named 'hypixel'
I am not sure if this is too relevant but my pip isn't the latest version and I get an error when I try and update it.
Edit: I have now successfully updated my pip. But even when I try and reinstall the package it still won't work.
Instead of using pip install python, use pip install hypixel. Then try to import it in your code using import hypixel.
In your question you say you used pip install python, did you mean to say pip install hypixel?
Also if you use python3 but have python3 installed make sure you use pip3.
You can install this with sudo apt-get install python3-pip (assuming you use a debian based distro). Then use sudo pip3 install hypixel
Edit:
For windows installation follow this link

ImportError: No module named 'ldap' Python 3.5

I'm running Python 3.5 (on Windows) and I have installed python-ldap from https://pypi.python.org/pypi/python-ldap/
I also tried using ldap3 but I keep getting an error saying
"ImportError: No module named 'ldap'
I looked around and saw some people saying there's no python-ldap for 3.5 so I installed 2.6 still getting the same error.
Is there a way to import ldap and make it work for Python 3.5?
Try the command below:
sudo apt-get install libsasl2-dev python-dev libldap2-dev libssl-dev
sudo pip3 install pyldap
Open a command line(cmd, powershell, git bash)
Check you python version
$ pyhton --version
Go to https://www.lfd.uci.edu/~gohlke/pythonlibs/
Download the library according with your python version and windows system
And install it on a command line using
pip install file_downloaded.whl
For example:
If you have python 3.5x and windows x64,
download the file python_ldap‑3.2.0‑cp35‑cp35m‑win_amd64.whl
pip install python_ldap‑3.2.0‑cp35‑cp35m‑win_amd64.whl
I'm running Apache Airflow on an Amazon EC2-Instance and I was getting "ImportError: No module named 'ldap3'. I used these two sites https://www.python-ldap.org/en/latest/installing.html and http://ldap3.readthedocs.io/installation.html to run the commands sudo python -m pip install python-ldap and sudo pip install ldap3 but my pip wasn't working for the last command so after some investigation I found out in my /usr/bin/ directory I had pip, pip-2.7, pip-3.6, and pip-python so I changed the command to pip-3.6 install ldap3 and then everything worked! Hope this helps someone.
I tried multiple approaches but finally, PyPI official documentation fixed this.
I was trying to execute on VS Code and did pip3 install python-ldap, but it didn't solve the issue. So I did the below from VS Code
# %% - This runs the below code as a Jupyter notebook cell
!pip3 install python-ldap
Now, I am able to import ldap and use it
Inside you folder, you can use virtualenv for python 3, example:
/opt/python-ldap-test
virtualenv -p /usr/bin/python3.5 venv
source venv/bin/activate
and then
pip install ldap3
It's extremely complicated to make things from 2.X to work in 3.X. Have you tried using it in a separate, 2.X only script and using it from there? It's not so unusual to combine python 2.X with 3.X in that manner or so I've heard.

ImportError: No module named 'pyrebase'

I'm currently working on a project with my raspberry pi. In this project I want to connect my raspberry to google firebase, therefore I have to use:
import pyrebase
I have installed pyrebase in terminal with:
pip install pyrebase
Also I'm aware that pyrebase doesn't support python 2, so i'm using python 3.4.2. I don't know why python can't find it, any ideas or suggestions?
If you have multiple versions of python installed, it may be confused on which version of pyrebase to install.
Try:
pip3 install pyrebase
Try to import like this:
from pyrebase import pyrebase
Works for me.
pip3 install pyrebase4
if this doesn't work
write this:
pip install pycryptodome
then
pip install pyrebase
Check if the pip you're using is working with your python version
pip --version
pip 8.1.2 from c:\python27\lib\site-packages (python 2.7)
Mine is working with python 2.7.
If you're working with the right python version try pip freeze or pip list to see the list of currently installed libraries, and check if the one that you're trying to install is there.
The Best Option is to install Ubuntu Mate in your raspberry pi as i have tried this on debian and got the same problem for absolutely no reason!! so i installed ubuntu mate and here you go it worked!!
pip install pyrebase <br>
This is for python 2.x
Please install python 3.x and pip3.x instead, then run
`pip3.x install pyrebase`
I was getting the "import error" of pyrebase. After checking this link I got the idea of problem, but was unable to find proper solution. After struggling for a day, I got the Solution. As I was using PYREBASE for my Engineering Project, I re-installed RASPBIAN-JESSIE stretch image on SD. Removed python2.7 and python3 and again installed python3 and then installing pyrebase and with frequent reboots. but it worked!
$ sudo apt-get remove python2.7
$ sudo apt-get remove python3
$ sudo reboot
$ sudo apt-get install python3
$ wget https://bootstrap.pypa.io/get-pip.py
$ sudo python3 get-pip.py
$ pip3 freeze #(displays about 15 lines, if pip is installed correctly)
$ pip3 list #(displays about 15 lines)
$ sudo pip3 install pyrebase
and now,
from pyrebase import pyrebase
and it did not gave import error.
For some reasons pyrebase Lib will only works in pycharm ide.
donwload Pycharm IDE Here !
1- Start Clean:
pip3 uninstall pyrebase4
pip3 uninstall pyrebase
2- Install Lib
pip3 install pyrebase
3- Restart your PC.
4- Run pycharm ide as administrator
5- Import it in Python:
from pyrebase import pyrebase
You should have it to work now!
This will work on latest versions of python
pip install pyrebase4

Categories

Resources