Attribute error: module 'requests' has no attribute 'Session' in pandas-DataReader - python

I am trying to follow this tutorial. However the line:
portfolio = web.DataReader(name=symbol, data_source='quandl', start=start, end=end)
is causing errors. After looking at the documentation, I have converted it to:
portfolio = pdr.DataReader(name=symbol, data_source='quandl', start=start, end=end)
but I still get the same error:
AttributeError: module 'requests' has no attribute 'Session'
this is being called from:
"/home/john/.conda/envs/optimizer/lib/python3.8/site-packages/pandas_datareader/_utils.py"
Also fails the same as this question. (Question closed with no solution)
Recreate
conda install pandas
conda install -c anaconda pandas-datareader
$ python
>>> import requests
>>> requests.Session()
AttributeError: module 'requests' has no attribute 'Session'
According to this request, that should work, but it does not. I think the error is with requests, not with pandas-datareader.
Edit :: added more information

check your spelling.
It should have been requests.session() not requests.Session()

Related

AttributeError: module 'tensorflow_docs' has no attribute 'plots'

I get some errors when I run the code in this tutorial by Google.
when I run the following piece of code:
plotter = tfdocs.plots.HistoryPlotter(metric = 'binary_crossentropy', smoothing_std=10)
plotter.plot(size_histories)
plt.ylim([0.5, 0.7])
It gives me the following error:
AttributeError: module 'tensorflow_docs' has no attribute 'plots'
How can I fix this issue?
pip install git+https://github.com/tensorflow/docs
import tensorflow_docs as tfdocs
import tensorflow_docs.plots
This worked for me when I had the same problem :)

AttributeError: module 'sst' has no attribute 'train_reader'

I am very new to sentiment analysis. Trying to use Stanford Sentiment Treebank(sst) and ran into an error.
from nltk.tree import Tree
import os
import sst
trees = "C:\\Users\m\data\trees"
tree, score = next(sst.train_reader(trees))
[Output]:
AttributeError Traceback (most recent call last)
<ipython-input-19-4101f90b0b16> in <module>()
----> 1 tree, score = next(sst.train_reader(trees))
AttributeError: module 'sst' has no attribute 'train_reader'
I think you're looking for https://github.com/JonathanRaiman/pytreebank, not https://pypi.org/project/sst/.
On the python side, that error is pretty clear. Once you import the right package, though, I'm not sure I saw train_reader but I could be wrong.
UPDATE:
I'm not entirely sure why you're running into the 'sst' not having the attribute train_reader. Make sure you didn't accidentally install the 'sst' package if you're using conda. It looks like the 'sst' is referring to a privately created module and that one should work.
I got your import working but what I did was I:
Installed everything specified in the requirements.txt file.
import sst was still giving me an error so I installed nltk and sklearn to resolve that issue. (fyi, im not using conda. im just using pip and virtualenv for my own private package settings. i ran pip install nltk and pip install sklearn)
At this point, import sst worked for me.
I guess you're importing the sst package selenium-simple-test, which is not what you're looking for.
Try sst.discover() , if you get the error
TypeError: discover() missing 4 required positional arguments: 'test_loader', 'package', 'dir_path', and 'names'
You are using the selenium-simple-test package

AttributeError: module 'IPython.core' has no attribute 'shadowns'

I'm running these lines
import dill
dill.load_session("session2.pkl")
and getting the error AttributeError: module 'IPython.core' has no attribute 'shadowns'.
I've saved this session on Google Colab Notebooks. How can I get rid of the error?
I used the simple workaround:
import IPython
IPython.core.shadowns = 1
For some extra packages missing like google or google.colab, I used
%%bash
mkdir google/colab
touch google/colab/__init__.py

AttributeError: module 'feedparser' has no attribute 'FeedParserDict'

I am trying to import feedparser in Python, and want to call FeedParserDict from the library feedparser, i.e., feedparser.FeedParserDict. But it leads to the following error:
"AttributeError: module 'feedparser' has no attribute 'FeedParserDict'."
Does it mean that "FeedParserDict" is not in the library feedparser (version 5.2.1). I find that "FeedParserDict" is present in previous version of feedparser (i.e., version 3.3). How can I cope with this error?
I've pip install feedparser==5.2.1 and "FeedParserDict" is present in it
import feedparser
print(feedparser.__version__)
print(feedparser.FeedParserDict)
output:
5.2.1
<class 'feedparser.FeedParserDict'>

Eclipse PyDev AttributeError: 'module' object has no attribute

I am trying to connect to the shopify api but am having difficulty connecting when using Eclipse+PyDev. When connection via python in a bash shell the same commands work OK
to install:
pip3 install --upgrade ShopifyAPI
shopify.py (my code)
import shopify
shop_url = "https://APIKEY:PASSWORD#mystore.myshopify.com/admin/products.json
shopify.ShopifyResource.set_site(shop_url)
The reference to shopify.ShopifyResouce.. throws the following in PyDev:
AttributeError: 'module' object has no attribute 'ShopifyResource'
I think it may be due to relative imports in the shopify module (the same code works fine in a terminal).
In shopify.py: (shopify API)
from shopify.resources import *
in shopify.resources: (shopify API)
from ..base import ShopifyResource
When I run
from shopify.base import ShopifyResource
ShopifyResource.set_site(shop_url)
I get ImportError: No module named 'shopify.base'; 'shopify' is not a package
Any ides how I can fix this?
The problem might be you created a shopify.py file in your IDE rename that file and that error will be solved

Categories