ImportError: No module named 'pyrebase' - python

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

Related

Is there any way that the display to be shown/rendered on my local machine? [duplicate]

I'm trying to install Pygame. I am running Windows 7 with Enthought Python Distribution. I successfully installed pip, but when I try to install Pygame using pip, I get the following error:
"Could not install requirement Pygame because of HTTP error HTTP error
400: Bad request for URL ..."
I can't find anything about this issue with a Google search, but I did find another Stack Overflow question that prompted the asker to use the following command:
pip install hg+http://bitbucket.org/pygame/pygame
This gave me the following error:
Cannot find command hg
I'm not sure what else to do, as everything I find with a Google search is for Mac, so I don't know how well I can follow those instructions on Windows.
Steps to install PyGame using pip
Install build dependencies (on linux):
sudo apt-get build-dep python-pygame
Install mercurial to use hg (on linux):
sudo apt-get install mercurial
On Windows you can use the installer: Download
Use pip to install PyGame:
pip install hg+http://bitbucket.org/pygame/pygame
If the above gives freetype-config: not found error (on Linux), then try sudo apt-get install libfreetype6-dev and then repeat 3.
Alternative way:
# Grab source
hg clone https://bitbucket.org/pygame/pygame
# Finally build and install
cd pygame
python setup.py build
sudo python setup.py install
Try doing this:
sudo apt-get install mercurial
sudo pip install hg+http://bitbucket.org/pygame/pygame
An update to this may be required, as it stands in version 1.9.1 it should simply install using:
pip install pygame
However, it look like there is a bug with their pypi repository, see:
https://bitbucket.org/pygame/pygame/issues/59/pygame-has-no-pypi-page-and-cant-be
So, if you want the most recent release, you have to point directly at the ftp file ala:
pip install http://www.pygame.org/ftp/pygame-1.9.1release.tar.gz
I suppose this will be fixed in the 1.9.2 release but for now this works.
I would note that the answer supplied by Pratyush works as well, but requires the user to install mercurial if they don't have it and downloads the trunk version, so really, not ideal unless you absolutely need it.
Caveat: I'm not familiar with the Enthought Distribution, so this might not help.
As you're trying to install on Windows, if you don't want to have to mess around with C compilers, there are pre-built binary wheels for pygame here: http://www.lfd.uci.edu/~gohlke/pythonlibs/#pygame
Select a package appropriate to you python version[0] and Windows architecture [1]. Download to C:\Users\User\Download\pip install E:\env\pygame-1.9.2a0-cp27-none-win_amd64.whl and install with pip install E:\env\pygame-1.9.2a0-cp27-none-win_amd64.whl
Mercurial binaries can be found on the same page, if you would like to install from source. This method would mean compiling pygame from source, for which you probably want to use this compiler package.
[0] python --version
[1] powershell "gwmi win32_operatingsystem | select osarchitecture"
The command below worked for me on Mac OS X El Capitan:
pip3 install pygame
Install on MAC:
brew install homebrew/python/pygame
Just
sudo pip install pygame
worked for me
Had this issue on macOS Sierra, where apt-get doesn't work.
Managed to solve the issue through the following steps:
First I had to install the Mercurial via Brew:
brew install mercurial
Then, I had to install Pygame dependencies:
brew install sdl sdl_image sdl_mixer sdl_ttf smpeg portmidi
Finally I used pip3 to install Pygame:
pip3 install pygame
Hope this helps!
Try
python3 -m pip install -U pygame --user
This worked twice for me on windows 7 and windows 10
The most current, the best way to install pygame is always available at:
https://www.pygame.org/wiki/GettingStarted
How to use pip depends on the operating system. So unless you have always updated and tested answers for 15 different operating systems then just send people to that page. All answers to this question are wrong for various different operating systems.
Currently, for windows, this is the way to install it in the cmd prompt. (If you already have pip installed, and people know what pip is... best just send people to the GettingStarted page).
py -m pip install pygame --user
I did use these instructions here from the official site.
But i had to change the python3 part of the command to just py.
Try: python -m pip install pygame
Or: py -m pip install pygame
Try pip install pygame or pip3 install pygame.
These should work for you.
If this does not work for you put -m before pip and python before
-m.
If putting -m does not work try reinstalling python
If you are working on windows, the command below should work fine
pip install pygame
If you are working on Linux, the command below should work fine
sudo apt-get install python-pygame
Type this in command prompt
pip install pygame
or
py -m pip install pygame
WINDOWS
If you are on a windows 10 device then you should use this command but first make sure you have Python installed from https://python.org, if you do run this in command prompt
py --version
and then whatever version it says you have (which you downloaded) keep it in mind we will use it later for now just incase try to upgrade pip incase you are on a outdated version I will be using 3.9 for the version for the rest of this as an example
py -3.9 -m pip --upgrade pip
After that if you have it already satisfied or it upgraded run this command in command prompt
py -3.9 -m pip install pygame
And wait for it to download
And to make sure it worked run this
py -3.9 -m pygame --version
If it shows the version you downloaded it!
MacOS
For MacOS do the same but then run this command to install it
python3 -m pip install -U pygame --user
or if it wont work
py -3.9 -m pip install -U pygame --user ( or just pip3 )
to see if it worked run this
python3 -m pygame.examples.aliens
or
py -3.9 -m pygame.examples.aliens
I hope this helped
I have never used Enthought distribution, but you could try to use Anaconda distribution which is also great too.
Anaconda Distribution (Any OS):
From the docs:
Update conda to the current version.
Type the following:
conda update conda
If a newer version of conda is available, type y to update:
Proceed ([y]/n)? y
Check to see if a package you have not installed named
“pygame” is available from the Anaconda repository (must be
connected to the Internet):
conda search pygame
Conda displays a list of all packages with
that name on the Anaconda repository, so we know it is available.
Install this package into the current environment:
conda install pygame
Check to see if the newly installed
program is in this environment:
conda list
Install on Windows (both python 2.7 and 3.7):
pip install pygame
Install on raspberry pi:
sudo pip3 install pygame (python 3.7)
sudo pip install pygame (python 2.7)
I think if you go to Command Prompt and type
py -m pip install pygame
that's what works for me
Here is a way: sudo install pygame Rasberry pi has it ready-installed
Install python 3.8 from python.org
Then install pygame (2.0) like this
pip install pygame==2.0.0.dev10
Make sure script path is registered in environment variables,
Make sure the python path is registered in environment variables,
also you dont have to enter entire url just write like this(windows only I dont use mac)
pip
pip install pygame
hope it work
command to install pygame is:
pip install pygame
run it in command prompt
Try doing this for python3:
python3 -m pip install pygame==1.9.6
and this for python2:
python -m pip install pygame==1.9.6
You don't have to type in the entire url. Just simply go to command prompt (windows) or terminal (mac) and then type in:
[windows] pip install pygame
[mac] python -m install pygame
hopefully that works :)
To install pygame with pip, use the following commands in the Command Prompt on Windows.
py -m pip download pygame
then...
py -m pip install pygame
You only have to do the download pygame one if it doesn't work when you use the install pygame command by itself.
You type py -m to show that it is using the module pip, which can be accessed through the command prompt.
This is for Windows. For Mac OS, use python -m pip install pygame
I know that there are already lot's of answers, but if you want to download a specific version of pygame, you can use pip:
pip install pygame==1.9.6
Pygame 1.9.6 is the latest version at the time of writing.
Pygame tells you how to install it here, in my personal experience this is what I do on windows to install it, open up command prompt and type python -m pip install pygame if that fails, check if you have more than one version of python installed if so you need to specify what version for example python3.5 -m pip install pygame the reason we do this from command prompt is that in the Python shell it doesn't understand what pip install is just to break it down a little python -m calls a python module in this case we want pip the next two arguments are what we want pip to do and what module/addon we want the action to be applied too

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!

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.

Unable to install Pygame using pip

I'm trying to install Pygame. I am running Windows 7 with Enthought Python Distribution. I successfully installed pip, but when I try to install Pygame using pip, I get the following error:
"Could not install requirement Pygame because of HTTP error HTTP error
400: Bad request for URL ..."
I can't find anything about this issue with a Google search, but I did find another Stack Overflow question that prompted the asker to use the following command:
pip install hg+http://bitbucket.org/pygame/pygame
This gave me the following error:
Cannot find command hg
I'm not sure what else to do, as everything I find with a Google search is for Mac, so I don't know how well I can follow those instructions on Windows.
Steps to install PyGame using pip
Install build dependencies (on linux):
sudo apt-get build-dep python-pygame
Install mercurial to use hg (on linux):
sudo apt-get install mercurial
On Windows you can use the installer: Download
Use pip to install PyGame:
pip install hg+http://bitbucket.org/pygame/pygame
If the above gives freetype-config: not found error (on Linux), then try sudo apt-get install libfreetype6-dev and then repeat 3.
Alternative way:
# Grab source
hg clone https://bitbucket.org/pygame/pygame
# Finally build and install
cd pygame
python setup.py build
sudo python setup.py install
Try doing this:
sudo apt-get install mercurial
sudo pip install hg+http://bitbucket.org/pygame/pygame
An update to this may be required, as it stands in version 1.9.1 it should simply install using:
pip install pygame
However, it look like there is a bug with their pypi repository, see:
https://bitbucket.org/pygame/pygame/issues/59/pygame-has-no-pypi-page-and-cant-be
So, if you want the most recent release, you have to point directly at the ftp file ala:
pip install http://www.pygame.org/ftp/pygame-1.9.1release.tar.gz
I suppose this will be fixed in the 1.9.2 release but for now this works.
I would note that the answer supplied by Pratyush works as well, but requires the user to install mercurial if they don't have it and downloads the trunk version, so really, not ideal unless you absolutely need it.
Caveat: I'm not familiar with the Enthought Distribution, so this might not help.
As you're trying to install on Windows, if you don't want to have to mess around with C compilers, there are pre-built binary wheels for pygame here: http://www.lfd.uci.edu/~gohlke/pythonlibs/#pygame
Select a package appropriate to you python version[0] and Windows architecture [1]. Download to C:\Users\User\Download\pip install E:\env\pygame-1.9.2a0-cp27-none-win_amd64.whl and install with pip install E:\env\pygame-1.9.2a0-cp27-none-win_amd64.whl
Mercurial binaries can be found on the same page, if you would like to install from source. This method would mean compiling pygame from source, for which you probably want to use this compiler package.
[0] python --version
[1] powershell "gwmi win32_operatingsystem | select osarchitecture"
The command below worked for me on Mac OS X El Capitan:
pip3 install pygame
Install on MAC:
brew install homebrew/python/pygame
Just
sudo pip install pygame
worked for me
Had this issue on macOS Sierra, where apt-get doesn't work.
Managed to solve the issue through the following steps:
First I had to install the Mercurial via Brew:
brew install mercurial
Then, I had to install Pygame dependencies:
brew install sdl sdl_image sdl_mixer sdl_ttf smpeg portmidi
Finally I used pip3 to install Pygame:
pip3 install pygame
Hope this helps!
Try
python3 -m pip install -U pygame --user
This worked twice for me on windows 7 and windows 10
The most current, the best way to install pygame is always available at:
https://www.pygame.org/wiki/GettingStarted
How to use pip depends on the operating system. So unless you have always updated and tested answers for 15 different operating systems then just send people to that page. All answers to this question are wrong for various different operating systems.
Currently, for windows, this is the way to install it in the cmd prompt. (If you already have pip installed, and people know what pip is... best just send people to the GettingStarted page).
py -m pip install pygame --user
I did use these instructions here from the official site.
But i had to change the python3 part of the command to just py.
Try: python -m pip install pygame
Or: py -m pip install pygame
Try pip install pygame or pip3 install pygame.
These should work for you.
If this does not work for you put -m before pip and python before
-m.
If putting -m does not work try reinstalling python
If you are working on windows, the command below should work fine
pip install pygame
If you are working on Linux, the command below should work fine
sudo apt-get install python-pygame
Type this in command prompt
pip install pygame
or
py -m pip install pygame
WINDOWS
If you are on a windows 10 device then you should use this command but first make sure you have Python installed from https://python.org, if you do run this in command prompt
py --version
and then whatever version it says you have (which you downloaded) keep it in mind we will use it later for now just incase try to upgrade pip incase you are on a outdated version I will be using 3.9 for the version for the rest of this as an example
py -3.9 -m pip --upgrade pip
After that if you have it already satisfied or it upgraded run this command in command prompt
py -3.9 -m pip install pygame
And wait for it to download
And to make sure it worked run this
py -3.9 -m pygame --version
If it shows the version you downloaded it!
MacOS
For MacOS do the same but then run this command to install it
python3 -m pip install -U pygame --user
or if it wont work
py -3.9 -m pip install -U pygame --user ( or just pip3 )
to see if it worked run this
python3 -m pygame.examples.aliens
or
py -3.9 -m pygame.examples.aliens
I hope this helped
I have never used Enthought distribution, but you could try to use Anaconda distribution which is also great too.
Anaconda Distribution (Any OS):
From the docs:
Update conda to the current version.
Type the following:
conda update conda
If a newer version of conda is available, type y to update:
Proceed ([y]/n)? y
Check to see if a package you have not installed named
“pygame” is available from the Anaconda repository (must be
connected to the Internet):
conda search pygame
Conda displays a list of all packages with
that name on the Anaconda repository, so we know it is available.
Install this package into the current environment:
conda install pygame
Check to see if the newly installed
program is in this environment:
conda list
Install on Windows (both python 2.7 and 3.7):
pip install pygame
Install on raspberry pi:
sudo pip3 install pygame (python 3.7)
sudo pip install pygame (python 2.7)
I think if you go to Command Prompt and type
py -m pip install pygame
that's what works for me
Here is a way: sudo install pygame Rasberry pi has it ready-installed
Install python 3.8 from python.org
Then install pygame (2.0) like this
pip install pygame==2.0.0.dev10
Make sure script path is registered in environment variables,
Make sure the python path is registered in environment variables,
also you dont have to enter entire url just write like this(windows only I dont use mac)
pip
pip install pygame
hope it work
command to install pygame is:
pip install pygame
run it in command prompt
Try doing this for python3:
python3 -m pip install pygame==1.9.6
and this for python2:
python -m pip install pygame==1.9.6
You don't have to type in the entire url. Just simply go to command prompt (windows) or terminal (mac) and then type in:
[windows] pip install pygame
[mac] python -m install pygame
hopefully that works :)
To install pygame with pip, use the following commands in the Command Prompt on Windows.
py -m pip download pygame
then...
py -m pip install pygame
You only have to do the download pygame one if it doesn't work when you use the install pygame command by itself.
You type py -m to show that it is using the module pip, which can be accessed through the command prompt.
This is for Windows. For Mac OS, use python -m pip install pygame
I know that there are already lot's of answers, but if you want to download a specific version of pygame, you can use pip:
pip install pygame==1.9.6
Pygame 1.9.6 is the latest version at the time of writing.
Pygame tells you how to install it here, in my personal experience this is what I do on windows to install it, open up command prompt and type python -m pip install pygame if that fails, check if you have more than one version of python installed if so you need to specify what version for example python3.5 -m pip install pygame the reason we do this from command prompt is that in the Python shell it doesn't understand what pip install is just to break it down a little python -m calls a python module in this case we want pip the next two arguments are what we want pip to do and what module/addon we want the action to be applied too

ImportError: No module named requests

I tried importing requests:
import requests
But I get an error:
ImportError: No module named requests
Requests is not a built in module (does not come with the default python installation), so you will have to install it:
OSX/Linux
Python 2: sudo pip install requests
Python 3: sudo pip3 install requests
if you have pip installed (pip is the package installer for python and should come by default with your python installation).
If pip is installed but not in your path you can use python -m pip install requests (or python3 -m pip install requests for python3)
Alternatively you can also use sudo easy_install -U requests if you have easy_install installed.
Linux
Alternatively you can use your systems package manager:
For centos: sudo yum install python-requests
For Debian/Ubuntu Python2: sudo apt-get install python-requests
For Debian/Ubuntu Python3: sudo apt-get install python3-requests
Windows
Use pip install requests (or pip3 install requests for python3) if you have pip installed and Pip.exe added to the Path Environment Variable. If pip is installed but not in your path you can use python -m pip install requests (or python3 -m pip install requests for python3)
Alternatively from a cmd prompt, use > Path\easy_install.exe requests, where Path is your Python*\Scripts folder, if it was installed. (For example: C:\Python32\Scripts)
If you manually want to add a library to a windows machine, you can download the compressed library, uncompress it, and then place it into the Lib\site-packages folder of your python path. (For example: C:\Python27\Lib\site-packages)
From Source (Universal)
For any missing library, the source is usually available at https://pypi.python.org/pypi/. You can download requests here: https://pypi.python.org/pypi/requests
On mac osx and windows, after downloading the source zip, uncompress it and from the termiminal/cmd run python setup.py install from the uncompressed dir.
(source)
It's not obvious to me which version of Python you are using.
If it's Python 3, a solution would be sudo pip3 install requests
To install requests module on Debian/Ubuntu for Python2:
$ sudo apt-get install python-requests
And for Python3 the command is:
$ sudo apt-get install python3-requests
Brew users can use reference below,
command to install requests:
python3 -m pip install requests
Homebrew and Python
pip is the package installer for Python and you need the package requests.
This may be a liittle bit too late but this command can be run even when pip path is not set. I am using Python 3.7 running on Windows 10 and this is the command
py -m pip install requests
and you can also replace 'requests' with any other uninstalled library
If you are using Ubuntu, there is need to install requests
run this command:
pip install requests
if you face permission denied error, use sudo before command:
sudo pip install requests
In my case requests was already installed, but needed an upgrade. The following command did the trick
$ sudo pip install requests --upgrade
On OSX, the command will depend on the flavour of python installation you have.
Python 2.x - Default
sudo pip install requests
Python 3.x
sudo pip3 install requests
On Windows Open Command Line
pip3 install requests
I had the same issue, so I copied the folder named "requests" from https://pypi.python.org/pypi/requests#downloadsrequests download to
"/Library/Python/2.7/site-packages".
Now when you use: import requests, it should work fine.
In the terminal/command-line:
pip install requests
then use it inside your Python script by:
import requests
or else if you want to use pycharm IDE to install a package:
go to setting from File in menu
next go to Python interpreter
click on pip
search for requests package and install it
Adding Third-party Packages to the Application
Follow this link
https://cloud.google.com/appengine/docs/python/tools/libraries27?hl=en#vendoring
step1 : Have a file by named a file named appengine_config.py in the root of your project, then add these lines:
from google.appengine.ext import vendor
Add any libraries installed in the "lib" folder.
vendor.add('lib')
Step 2: create a directory and name it "lib" under root directory of project.
step 3: use pip install -t lib requests
step 4 : deploy to app engine.
Try sudo apt-get install python-requests.
This worked for me.
If you are using anaconda as your python package manager, execute the following:
conda install -c anaconda requests
Installing requests through pip didn't help me.
The only thing that worked for me:
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py
pip install requests
Facing the same issue but unable to fix it with the above solution, so I tried this way and it worked:-
curl https://bootstrap.pypa.io/pip/2.7/get-pip.py --output get-pip.py
sudo python2 get-pip.py
python -m pip install requests
For windows just give path as cd and path to the "Scripts" of python and then execute the command easy_install.exe requests.Then try import requests...
I have had this issue a couple times in the past few months. I haven't seen a good solution for fedora systems posted, so here's yet another solution. I'm using RHEL7, and I discovered the following:
If you have urllib3 installed via pip, and requests installed via yum you will have issues, even if you have the correct packages installed. The same will apply if you have urllib3 installed via yum, and requests installed via pip. Here's what I did to fix the issue:
sudo pip uninstall requests
sudo pip uninstall urllib3
sudo yum remove python-urllib3
sudo yum remove python-requests
(confirm that all those libraries have been removed)
sudo yum install python-urllib3
sudo yum install python-requests
Just be aware that this will only work for systems that are running Fedora, Redhat, or CentOS.
Sources:
This very question (in the comments to this answer).
This github issue.
Python Common installation issues
These commands are also useful if Homebrew screws up your path on macOS.
python -m pip install requests
or
python3 -m pip install requests
Multiple versions of Python installed in parallel?
You must make sure your requests module is not being installed in a more recent version of python.
When using python 3.7, run your python file like:
python3 myfile.py
or enter python interactive mode with:
python3
Yes, this works for me. Run your file like this: python3 file.py
I have installed python2.7 and python3.6
Open Command Line to ~/.bash_profile I find that #Setting PATH for Python 3.6 , So
I change the path to PATH="/usr/local/Cellar/python/2.7.13/bin:${PATH}" ,
(please make sure your python2.7's path) ,then save.
It works for me.
if you want request import on windows:
pip install request
then beautifulsoup4 for:
pip3 install beautifulsoup4
Please try the following. If one doesn't work, skip to the next method.
pip install requests
or...
pip3 install requests
or...
python -m pip install requests
or...
python3 -m pip install requests
or...
python -m pip3 install requests
If all of these don't work, please leave a comment!
How does this work? Depending on the operating system you currently use, the pip command may vary or not work on some. These are the commands you may try in order for a fix.
In case you hit pip install requests and had an output massage of Requirement already satisfied but yet you still get the error: ImportError: No module named requests.
This is likely to happen when you find yourself in a different interpreter/virtual environment.
You can copy and append the path of the module into your working environment.
Note: This path usually comes with the message Requirement already satisfied
Before import requests, you should import sys and then append the copied path.
Example:
Command Prompt:
pip install requests
Output:
Requirement already satisfied: requests in /usr/local/lib/python3.9/site-packages
import sys
sys.path.append("/usr/local/lib/python3.9/site-packages")
import requests
I solved this problem.You can try this method.
In this file '.bash_profile', Add codes like alias python=/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7
Type this command in Command Prompt (Windows) or Terminal (Linux/macOS):
pip install requests
My answer is basically the same as #pi-k. In my case my program worked locally but failed to build on QA servers. (I suspect devops had older versions of the package blocked and my version must have been too out-of-date) I just decided to upgrade everything
$ pip install pip-review
$ pip-review --local --interactive
You get an import error because requests are not a built-in module instead, it is created by someone else and you need to install the requests.
use the following command on your terminal then it will work correctly.
pip install requests
Install python requests library and this error will be solved.
I found that my issue was VSCode was reading from the wrong Python Interpreter. This youtube tutorial solved it for me.
If you are using anaconda
step 1:
where python
step 2:
open anaconda prompt in administrator mode
step 3:
cd <python path>
step 4:
install the package in this location

Categories

Resources