Python 3.5 Attribute Error - requests - attributes

I am new to programming and trying to teach myself Python using online tutorials. I am using PyCharm to code.
I am trying to use the requests module to get a website.
To test requests was working, I entered:
import requests
requests.get('http:\google.com')
Yet I received an error message:
Traceback (most recent call last):
File "C:/Users/Avraham Tzion/PycharmProjects/untitled/Spider.py", line 16, in
requests.get('http://google.com')
AttributeError: module 'requests' has no attribute 'get'
Process finished with exit code 1
The requests I have installed is the newest version, 2.9.1.
How can I run the 'get' function? I can't figure out why it isn't working!

trying your example, it worked for me.
import requests
>>> requests.get('http://google.com')
<Response [200]>
created new, clean virtualenv
pip install requests # which downloaded version 2.9.1)
opened python interpreter
tried the following example

Isnt request an extermal module?
Have you tried
pip install requests

Related

Python Module not found, but it is installed?

I wanted to make an Instagram bot so I can automate my posts and whatever. My problem is, I get the following Error when I try importing the module/library named "instagrapi":
Exception has occurred: ModuleNotFoundError
No module named 'instagrapi'
File "C:\Users\Simon\Desktop\Py\bot.py", line 1, in <module>
from instagrapi import Client
the error is in line 1 of my code, which simply states "from instagrapi import Client"
Now to my question: I already installed instagrapi, but VSCode tells me I didn't. I installed Python 3.11 but it runs in 3.10 or what so ever.
If someone can help me, please do so, thanks in advance
I tried reinstalling the library and restarting vscode, but it didn't help.
I'm running out of ideas

I'm struggling to get 'beautifulsoup4' working in pycharm on my windows10 laptop

Pycharm seems to accept bs4 but doesn't recognize beautiful soup - even though i've made sure it is installed via pip in the command terminal and via miniconda. I've also gone to settings (in pycharm) and
have the packages bs4 and beautifulsoup4 installed already (with the latest versions), I am using Python 3.9.
The following is the error message I get:
C:\Users\joe_h\AppData\Local\Programs\Python\Python39\python.exe C:/Users/joe_h/AppData/Roaming/JetBrains/PyCharmCE2020.3/scratches/scratch.py
Traceback (most recent call last):
File "C:\Users\joe_h\AppData\Roaming\JetBrains\PyCharmCE2020.3\scratches\scratch.py", line 1, in <module>
from bs4 import beautifulsoup4
ImportError: cannot import name 'beautifulsoup4' from 'bs4' (C:\Users\joe_h\AppData\Roaming\Python\Python39\site-packages\bs4\__init__.py)
Process finished with exit code 1
Instead of trying
from bs4 import beautifulsoup4
(which is wrong way to do it)
instead do
from bs4 import BeautifulSoup

How can I resolve python requests package import error?

I am new to python and am having trouble getting the python requests package to run. I have searched around for answers, but it seems that the question is most often answered with instructions on installing the requests package, which you will see I have already done.
Before I start, my specs are as follows:
OS: MacOSX Catalina 10.15.7
Shell: iTerm2 Build 3.3.12
Python Versions:
System: 2.7.16
pyenv: 3.9.0
Use Case: I am experimenting with web scraping and am attempting to write a simple program that will scrape some data from a local car dealership's website (e.g. scrape info on cars listed under $20k).
Before starting the project, I installed the requests package with the following command:
% pip3 install requests
I then opened up a vim file and wrote the following, just to ensure that the requests package was working properly:
import requests
URL = 'cardealerurl.com/query'
page = requests.get(URL)
I saved the file as carScrape.py.
Then I went beck to the shell and executed the following:
python carScrape.py
on execution, I receive the following error message:
Traceback (most recent call last):
File "carScrape.py", line 1, in <module>
import packages.requests
ImportError: No module named packages.requests
Any help with this would be greatly appreciated. If more information is needed, please just let me know and I will provide whatever I can. Thank you all so much.
I was able to solve this by running the following commands:
% sudo -H pip3 uninstall pip
% python3 -m ensurepip
% pip3 install requests
This was after a pretty long chunk of time trying other solutions that did not work. I also had to start a new shell to get rid of the error message.

How to get python API to access Smartsheet

I am following the smartsheet API's python-sdk example to do some practice.
Below are my steps (using Python 3.4.4 on macOS 10.7.5):
installed the SDK package from their GitHub repo
installed pip using pip install smartsheet-python-sdk in my terminal
created a .py file and moved it into the SDK file
Issue
When I run it, I got following error message:
Traceback (most recent call last):
File "/Users/canny_aiyaya/Desktop/smartsheet-python-sdk-master/smartsheet/charity.py", line 5, in <module>
import smartsheet
File "/Users/canny_aiyaya/Desktop/smartsheet-python-sdk-master/smartsheet/smartsheet.py", line 28, in <module>
import requests
ImportError: No module named 'requests'
Code in the .py file
import smartsheet
ss_client = smartsheet.Smartsheet(access_token)
ss_client.errors_as_exceptions(True)
Analysis
I looked for some possible solutions, and try to install requests on my terminal using sudo pip3 install requests, but it shows:
No matching distribution found for requests
This is my first time trying to use API on Smartsheet, any supports/links/videos will very helpful.
There are a number of dependencies. You can run python setup.py install from the Smartsheet SDK directory to install them.

python module not found error

This question has been asked a few times, but the remedy appears to complicated enough that I'm still searching for a user specific solution.
I recently installed Quandl module using pip command. Even after successful installation my python idle is still showing
Traceback (most recent call last):
File "F:\Python36\Machine Learning\01.py", line 3, in <module>
import Quandl
ModuleNotFoundError: No module named 'Quandl'
I have used import command in my code.
I am using python 3.6.1 version.
I am working on a windows 10 Desktop.
I have also tried re-installation of module.
You can better navigate to your python scripts folder and open a command window there and try pip3 install quandl .Hope this helps.

Resources