I'm trying to use Python's requests module, so I installed it using
pip install requests,
then it appears that requirement is already satisfied in Miniconda library. On my script, I import request as
import requests,
and when I run the script I get ModuleNotFoundError. However, if I do the same thing in Jupyter, the module works and no error appears. What should I do to use that module locally in my editor?
Related
I have imported the requests package (pip install requests) and it shows when I run pip list, but when I run code that uses import requests, it gives me the error "ModuleNotFoundError: No module named 'requests'". I've tried updating pip but so far nothing has worked.
As the title says, apparently VsCode doesn't recognize several modules that I already installed on my MacBook. For example,
from bs4 import BeautifulSoup
from requests import request
from tkinter import *
And the error message says,
No module named 'bs4'
File "/Users/my_name/Desktop/VsCode Projects/weather_detecter/main.py", line 7, in
<module>
from bs4 import BeautifulSoup
Also, it says the same thing on requests, but not on tkinter. I tried sudo pip, -m, pip3 on both terminal.app and VsCode terminal, but the outcome is still the same. How can I fix this?
You might need to select the correct python interpreter version first and then try importing the modules.
OR, open terminal in VS Code and try reinstalling the modules with the command python3 -m pip install <module_name>
Probably stupidly I tried to install the latest version of Python, in this case using the download from python site, but after doing that I was then getting python still running on the previous version python-3.6. I'm on OSX and was using sublime.
So I have been trying to work out how to update it to use the newest version. I've followed; https://opensource.com/article/19/5/python-3-default-mac.
All of the responses to queries now point to the python-3.9.5 version. So that's great and my runtime is using that. However after installing the requests using pip install I get the following error when running.
import requests
ModuleNotFoundError: No module named 'requests'''
[path: /Library/Frameworks/Python.framework/Versions/3.9/bin:/Library/Frameworks/Python.framework/Versions/3.6/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin]
I stumbled upon Modules are installed using pip on OSX but not found when importing which I have been trying to work through.
I have been able to run the import command successfully in terminal, however it's intermittent as I've tried again and it's broken, so I'm lost. I'm running it something trying to run the python3.6 version, which after updating I followed these instructions to remove when I have uninstalled that from my mac https://www.macupdate.com/app/mac/5880/python/uninstall.
If there is any ideas, would love some help, mainly to try and tell me what that error message is telling me.
In particular, what does this mean?
[path: /Library/Frameworks/Python.framework/Versions/3.9/bin:/Library/Frameworks/Python.framework/Versions/3.6/
I should clarify too; when I run 'pip list'
I see
requests 2.25.1
Assuming that you are not installing requests package properly, and assuming your python executable is named python:
python -m pip install requests
If however, your python executable is named something else instead, e.g. python3, replace python with that name:
python3 -m pip install requests
I installed Python using Homebrew, I installed Pip and then using Pip I downloaded the Requests module.
Just to double check I tried to install it again and got a confirmation in terminal that it was already installed:
Requirement already satisfied: requests in /usr/local/lib/python2.7/site-packages
I then tried to write a pretty simple script to call Git and see if I can get a response. But when I run it I get an error message. Here's the script and message:
import requests
response = requests.get('https://api.github.com/events')
print (response)
Message:
PythonTesting/main.py", line 5, in <module>
import requests
ImportError: No module named requests
I'm a beginner in programming. Today, I was in the same problem. I spent many hours trying fix this problem. For me worked:
open prompt comand
cd (path of scripts directory in venv - my project on VisualStudio Code)
pip install requests
Then, I opened VS and put my code to go. It's work well.
Make sure you are running the code in version 2.7 as you have installed the request package for 2.7 only. If by mistake you are running the code on version 3, then that request package won't work. In that case, you need to install the requests for python3.
I tried to import requests in my python scripts but it shows error
>>>import requests
ImportError: No module named requests
So I tried to install it using easy_install
Path\easy_install.exe requests
in Windows, but it shows no response and when I run import again, it shows the same error.
Make sure you have requests and pyvmomi directories located under c:\pythonXXX\Lib\site-packages.
In case of absence, try to install those packages via pip on windows(here you have the instructions to install pip on windows).
Once you have done installation of pip, open the CMD prompt with administrative privilege and use the following commands to install the required python packages :
pip install requests pyvmomi
Now you could see that the packages are successfully installed.
After this, open the "System Properties" window and select "Advanced" tab and click the button "Environment variables" to set required path variables as shown below :
PYTHONHOME - "c:\Python278"
PYTHONPATH - "c:\Python278\Lib"
Edit the system variable Path and append the following :
%PYTHONHOME%;%PYTHONPATH%;
Finally open idle or python shell and import the packages as follows :
import requests
import pyVmomi
Now you are able to import with out any problem. Whenever you import packages, also check the spelling and case sensitive of the name.
Open cmd.exe that run this command:
pip install requests
Another solution is to install Anaconda which is Python distribution that comes with great package manager from here: Anaconda
Anconda python comes with built in requests library (and many more useful libraries)