Getting import error when using gensim.summeraization - python-2.7

I am trying to use gensim's summarizer and keywords to extract important keywords and summarizing contents. However, I am getting the following error:
from gensim.summarization import summarize
Traceback:
ImportError Traceback (most recent call last)
<ipython-input-12-70743b938b65> in <module>()
----> 1 from gensim.summarization import summarize
ImportError: No module named summarization
I checked the version which is gensim 0.10.0. I am using Anaconda distribution and installed gensim using
conda install gensim
Any help would greatly help.
Thanks

Please update gensim to the latest version.
pip/conda install --upgrade gensim

Related

How can I import the csvsql to Python 2.7

I have successfuly installed csvkit using conda install ...
However, when I try to import the libraries in Python 2.7 Spyder, I get error messages:
import csvsql
Traceback (most recent call last):
File "<ipython-input-5-303a60a6b1ac>", line 1, in <module>
import csvsql
ImportError: No module named csvsql
import csvkit
Traceback (most recent call last):
File "<ipython-input-7-ca8a99ae9834>", line 1, in <module>
import csvkit
ImportError: No module named csvkit
I looked at the documentation -- they describe the installation process but not how the library is loaded in Python.
Moreover, I had an analogous problem with httplib2. I installed it successfuly but when I tried to import it in Spyder I received an analogous error message (No module named httplib2).
(I use Anaconda 3 and Spyder on Windows 11)
Any ideas? Thank you in advance.
I asked this question on the csvkit GitHub / issues forum.
The answer given was: You should use agate on which csvkit now relies for all its operations. See https://github.com/wireservice/agate.
I'm with you -- it would be wonderful to use csvkit as a command-line tool and a library, but it's authors don't see it that way. The full issue: https://github.com/wireservice/csvkit/issues/670

Error in keras - name 'Dense' is not defined

I'm new to Deep Neural Network libraries in python. I've installed Theano & keras in my windows system by following these steps(I already had anaconda):
Install TDM GCC x64.
Run the below code from command prompt
conda update conda
conda update --all
conda install mingw libpython
pip install git+git://github.com/Theano/Theano.git
pip install git+git://github.com/fchollet/keras.git
When I'm running the following code in Ipython,
import numpy as np
import keras.models
from keras.models import Sequential
model = Sequential()
model.add(Dense(32, input_shape=(784,)))
model.add(Activation('relu'))
it is showing the following error:
NameError
Traceback (most recent call last)
----> 1 model.add(Dense(32, input_shape=(784,)))
NameError: name 'Dense' is not defined
Here is the error message screenshot.
How come sequential was imported successfully and 'Dense' was not defined?
You need from keras.layers import Activation, Dense.
I had a similar problem in tensorflow 2.0 and solved it by using
from tensorflow.keras.layers import Dense
For TensorFlow 2.6 you should do this:
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense

(Scikit - Python) ImportError: No module named scipy

I'm trying to install Scikit and run a python file that only has:
import sklearn
To check if Scikit works. This is the error I get:
Traceback (most recent call last):
File "hello-world.py", line 1, in
import sklearn
File "/Library/Python/2.7/site-packages/sklearn/init.py", line 57, in
from .base import clone
File "/Library/Python/2.7/site-packages/sklearn/base.py", line 9, in
from scipy import sparse
ImportError: No module named scipy
I have been at this for hours now. My python version is Python 2.7.11
which -a python
gives me this:
/usr/local/bin/python
/usr/bin/python
/Library/Frameworks/Python.framework/Versions/2.7/bin/python
/Users/Iliad/anaconda/bin/python
I had had Python 3.5 Installed before, but downloaded Anaconda for 2.7, but can't make sure it is set to work with that version.
Thanks!
I will start with
python --version
Just to be sure
and then in python repl. Use this
import site
site.getsitepackages()
This would give you something like :
['/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages']
Check in all the dist-packages for scipy. My guess is that it is not there.
If you have any other "dist-packages" type of folder then you should add that to your PYTHONPATH.

ImportError: Numpy OpenBLAS flavour is needed for this scipy build

I use python 2.7 on PyCharm and I try to make a surface from a file points and i read that the way from do this is through libraries matplotlib, mpl_toolkits. But when i run the code that i copy from example's web i have this error:
C:\Python27\python.exe C:/Users/rublloal/PycharmProjects/untitled3/matplotlib1.py
Traceback (most recent call last):
File "C:/Users/rublloal/PycharmProjects/untitled3/matplotlib1.py", line 10, in
from scipy.misc import imread # Cargo imread de scipy.misc
File "C:\Python27\lib\site-packages\scipy__init__.py", line 122, in
raise ImportError("Numpy OpenBLAS flavour is needed for this scipy build.")
ImportError: Numpy OpenBLAS flavour is needed for this scipy build.
thanks
I use python 2.7 on PyCharm and I downgrade the scipy 0.18 to 0.16 and I had the same problem as you, but I reinstall numpy - (numpy-1.10.0b1-cp27-none-win32.whl) by pip.
You can find the wheel here: https://pypi.anaconda.org/carlkl/simple/numpy/
and problem disappear.
Maybe I answered to late, but I hope it will help someone else :)

python 2.7 module pandas not installing "cannot import name hashtable"

I tried looking for an answer to this around the forum/google, but I can't find anything. My issue is this (from python console):
>>> import pandas
cannot import name hashtable
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\site-packages\pandas\__init__.py", line 6, in <module>
from . import hashtable, tslib, lib
ImportError: cannot import name hashtable //also can't import name NaT somtimes
I ran the windows 1-click installer prior to attempting the import. I'm running everything 32-bit. The pandas installer is for python 2.7.
Here's a list of modules that I have correctly imported into Python.
setuptools
pip
mox
dateutil
six
numpy
SQLAlchemy
I'm on windows 7.
I also have anaconda installed, but that was really just a "hail mary" after I tried everything else. My end goal is to install the ultra-finance module. However, it seems to require pandas, hence me being stuck.
I'm a python noob, so please don't assume I know anything. Thanks.
EDIT: please let me know if I can provide any extra information.
The recommended way to install pandas is via pip:
pip install pandas
This hashtables error arises from the cython files not being built. This error message will be more informative from 0.11.1.
Try running your code in Spyder (Anaconda -> Spyder). It worked for me.
Check that you have python scripts included in your system path variable. In my case I had to add "C:\Python27\Scripts"
I was having a similar problem when downloading Pandas to my Windows 8 system. The first error I had was an egg error, but after installing some packages I think I have the solution.
First look at the previous pip errors with Pandas, make sure you have the most updated pip.
The second part is downloading wheel using
pip install wheel
After installing wheel and having the dependencies for panda and using pip it worked correctly.