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'>
Related
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
My goal is to acquire image from an Allied Vision camera thanks to Python (Anaconda 3.7). For that I tried to use the "Pymba" package but I get the error : “AttributeError: module has no attribute”.
I looked in the previous posts but I didn't find any working solution. I put below some of my tests.
Here is my code :
import pymba
with pymba.Vimba() as vimba:
print (vimba.getVersion())
system = vimba.getSystem()
The precise error :
File "<ipython-input-2-ff80570a1f3d>", line 3, in <module>
print (vimba.getVersion())
AttributeError: 'Vimba' object has no attribute 'getVersion'
And here are some informations that could be usefull about my research to solve this problem:
I checked if the package was correctly installed.
from pymba import Vimba, PYMBA_VERSION
print(PYMBA_VERSION)
print(Vimba.version())
0.3.2
1.7.0
Despite the fact that I don't have any other file named "Pymba", I checked what file was imported:
print(pymba.__file__)
C:\Users\agricultu\Anaconda3\lib\site-packages\pymba\__init__.py
I don't have either a previous file named "getVersion" and I get the same error for every other function of the package anyway.
I'm running out of ideas and I hope one of you will be able to help me.
Overview
from elasticsearch import Elasticsearch does not work.
import elasticsearch
e = elasticsearch.Elasticsearch(...)
does work.
Deets
I am trying to use a simple Elasticsearch client in python using AWS (ssh'd on an Amazon linux e3 machine). The code I am copying is here. I am unable to import the Elasticsearch class as described in the guide.
Using from elasticsearch import Elasticsearch gives me the error: ImportError: cannot import name 'Elasticsearch'.
I opened the python3 cli to check it out. If I type from elasticsearch import E and tab-complete, I get the following suggestions: EOFError( Ellipsis EnvironmentError( Exception(. However from elasticsearch import Ellipsis gives me ImportError: cannot import name 'Ellipsis'.
If I type import elasticsearch, then on the next line elasticsearch. and hit tab to autocomplete, I get the full range that I would expect (Elasticsearch(, RequestsHttpConnection(, etc.).
I assume that this has something to do with the way/where it is installed.
I used pip3 install elasticsearch --user to install it originally. I uninstalled it (pip3 uninstall elasticsearch) and returned to the python cli. from elasticsearch import E still gives me EOFError( Ellipsis EnvironmentError( Exception( on the tab-complete, but from elasticsearch import Ellipsis now returns ModuleNotFoundError: No module named 'elasticsearch', as does just import elasticsearch.
Not really quite sure what is up. I did not tag this as elasticsearch because it might be a user error :P
which python3: /usr/bin/python3
which pip3: ~/.local/bin/pip3
pip3 --version: pip 18.1 from /home/ec2-user/.local/lib/python3.6/site-packages/pip (python 3.6)
My problem was that I had named my file the same thing as the module I was trying to import from - elasticsearch.py. As user2357112 states, I became hung up on the incorrect autocomplete.
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
This is the error I get! I'm guessing I'm missing a module named formats? I'm very new to installations with django. So bear with me. Previously I had gotten error that vectorformat.formats module was missing. So I did sudo pip install vectorformats. This lead to the error I have now. See below:
from vectorformats.formats import django, geojson
ImportError: No module named formats
Django Version: 1.6.1
Exception Type: ImportError
Exception Value:
No module named formats
Exception Location: /usr/local/lib/python2.6/dist-packages/leaflet_storage/views.py in , line 25
Python Executable: /usr/bin/python
Python Version: 2.6.6
from vectorformats.Formats import ...
note the uppercase 'F'
documentation here
you'll have the same error message with django and geojson