Error with 'from matplotlib.finance import quotes_historical_yahoo' - python-2.7

I'm reading a financial book about Python. In the book the author is importing historical stock prices from yahoo finance. The very first line of code:
from matplotlib.finance import quotes_historical_yahoo
Causes the following error:
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
from matplotlib.finance import quotes_historical_yahoo
ImportError: cannot import name quotes_historical_yahoo
I went to this link and downloaded the zipped file.
https://github.com/matplotlib/matplotlib
I unzipped everything into this folder:
C:\Python27\matplotlib
I opened the CMD window, naviagted to that folder, and entered this:
python setup.py install
That gives me this error.
Even the traditional pip install doesn't work for me.
Does anyone have any idea what's wrong? I'm using Windows 7 and Python 2.7.
Thanks.

Related

Why xlsxwriter module does not work like other modules?

Traceback (most recent call last):
File "F:TC.py", line 1, in <module>
import xlsxwriter
ImportError: No module named xlsxwriter
I am getting this error even after trying every possible answer given to this problem earlier.
I am using python 2.7 in windows
I have installed xlsxwriter using pip
I have tried reinstalling python shell but it doesn't work.

PyDSTool with anaconda not installing properly

I am trying to install PyDSTool with anaconda2 (conda install PyDSTool), which seems to go well. But when I open spyder and import PyDSTool, it gives me error
import PyDSTool
Traceback (most recent call last):
File "<ipython-input-1-a214100b00aa>", line 1, in <module>
import PyDSTool
File "/home/user/anaconda2/lib/python2.7/site-packages/PyDSTool/__init__.py", line 76, in <module>
raise RuntimeError("SciPy v0.5.1 or above is required")
RuntimeError: SciPy v0.5.1 or above is required
I tried to change parseUtils.py as per this suggestion: import of package PyDSTool doesn't work
but still the same error. I certainly have SciPy 1.0 and python 2.7.
I ran into this problem recently. The accepted answer here (PyDSTool do not recognize SciPy version) is still effective today at solving this problem.
Basically download PyDSTool from here (https://github.com/tkf/pydstool/tree/tkf) instead of sourceforge.

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

Pyside Import Error "No Module named Ctypes"

Im pretty new to working with this side of python so pardon me if I'm a bit off kilter.
I am trying to incorporate PySide into Cryengine's Python 2.7.5 Integration; I used PIP to install the Site - Package to Cryengines Python Directory using the pip install PySide.whl -t CRYENGINE/Editor/Python/Lib/Site - Package command through command prompt.
Here is the script I am trying to run in the Python Shell Of CryEngine:
import sys
import site
site.ENABLE_USER_SITE
print site.USER_BASE
site.addsitedir("F:\SteamLibrary\steamapps\common\CRYENGINE\Editor\Python\Lib\site-packages\PySide")
from PySide import QtGui
app = QtGui.QApplication(sys.argv)
wid = QtGui.QWidget()
wid.resize(250, 150)
wid.setWindowTitle('Simple')
wid.show()
sys.exit(app.exec_())
I get the following error in the Python script terminal:
] from PySide import QtGui
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Python27\lib\site-packages\PySide\__init__.py", line 41, in <module>
_setupQtDirectories()
File "C:\Python27\lib\site-packages\PySide\__init__.py", line 9, in _setupQtDirectories
from . import _utils
File "C:\Python27\lib\site-packages\PySide\_utils.py", line 31, in <module>
import ctypes
ImportError: No module named ctypes
I used pip to install the PySide wheel files. So its really weird that I am getting this error. I double checked the files that ctypes uses are there, and in the Python 2.7 installation. And all of them are there. I tested this using Python Shell, and it works great! But for some reason when I run it through CryEngine's python 2.7.5 integration even though the file path is to C:\Python27 where all of those file Ctypes files are!
I am almost sure that I am oversimplifying the problem, but I'm not sure where to start getting this problem solved. I want to get this working so I can build an integration that will work for the whole CryEngine Community. I've looked all over the place for a solution, but am really at the end of my rope here.
Any help would be greatly appreciated!!

dispersion_plot not working inspite of installing matplotlib

i have installed matplotlib using pip in ubuntu 14.04 LTS.. but on running dispersion_plot this is showing the following error ..
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/nltk/text.py", line 455, in dispersion_plot
from nltk.draw import dispersion_plot
ImportError: cannot import name dispersion_plot
I am new to python... can anyone suggest if there is a better way of installing matplotlib in nltk.
The examples of the online book are not quite right.
You may try this:
from nltk.draw.dispersion import dispersion_plot
words = ['Elinor', 'Marianne', 'Edward', 'Willoughby']
dispersion_plot(gutenberg.words('austen-sense.txt'), words)
You may also call it from a text directly:
from nltk.book import text1
from nltk.draw.dispersion import dispersion_plot
dispersion_plot(text1, ['monstrous'])
this way you import the function directly instead of calling the funcion from text object.
I realized this watching at the source code directly.
Hope this work for you
After importing it using spyder, this is how the plot would look.