Can't Get PyDot to Work in Python 3.5 - python

While using Keras library for machine learning, I keep getting the error:
Traceback (most recent call last):
File "rnn2.py", line 253, in <module>
from keras.utils.visualize_util import plot
File "C:\Program Files\Anaconda2\envs\py35\lib\site-packages\keras\utils\visualize_util.py", line 13, in <module>
raise RuntimeError('Failed to import pydot. You must install pydot'
RuntimeError: Failed to import pydot. You must install pydot and graphviz for `pydotprint` to work.
My system is Windows 10, Anaconda 3.5 environment. I have tried all of the solutions mentioned in github issues and stack overflow:
like installing pyparsing , pydot-ng, graphviz etc. Nothing is working, I keep getting the error.
What to install to remove the error? Please help. Thanks.

Related

SKlearn importError

Hi just updated my version of python from 3.7 to 3.8 I am using pycharm IDE and sklearn was working perfectly fine in the previous version but now when I try to run code that was
However after updating my version it keeps giving the following error.
"C:\Program Files\Python\python.exe" C:/Users/SmithyB/Desktop/test/K-Means.py
Traceback (most recent call last):
File "C:/Users/SmithyB/Desktop/test/K-Means.py", line 6, in <module>
from sklearn.cluster import KMeans
File "C:\Program Files\Python\lib\site-packages\sklearn\__init__.py", line 80, in <module>
from .base import clone
File "C:\Program Files\Python\lib\site-packages\sklearn\base.py", line 21, in <module>
from .utils import _IS_32BIT
File "C:\Program Files\Python\lib\site-packages\sklearn\utils\__init__.py", line 20, in <module>
from scipy.sparse import issparse
File "C:\Program Files\Python\lib\site-packages\scipy\__init__.py", line 119, in <module>
from scipy._lib._ccallback import LowLevelCallable
File "C:\Program Files\Python\lib\site-packages\scipy\_lib\_ccallback.py", line 1, in <module>
from . import _ccallback_c
ImportError: cannot import name '_ccallback_c' from 'scipy._lib' (C:\Program Files\Python\lib\site-packages\scipy\_lib\__init__.py)
I have made sure that the interpreter is correct. I have made sure that I have uninstalled older versions of python from my computer but unfortunately still no luck.
I will really appreciate it if someone can point out how to solve this problem.
Thanks
Try removing Scipy folder from C:/Users/SmithyB/AppData/Roaming/Python/Python36/site-packages/scipy
Reinstall using pip install scipy
Thanks for all your input, I couldn't have solved the problem without you guys.
I am posting how I solved the problem with the hope that it will be helpful to someone.
Since the problem was originally with using the SK-Learn library I uninstalled scikit-learn
pip uninstall scikit-learn
and then reinstalled it.
pip install scikit-learn
the error did not go away after that so I followed the suggestion of uninstalling scipy
pip uninstall scipy
and then reinstalling it.
pip install scipy
I ran a code that I had written which uses sklearn previously and it worked.

ImportError while running python program

I have tried all the import methods and upgrading the libraries but still I'm unable to get over this error. I have downloaded and installed all the nltk and corpus data programmatically and it is working in the python shell but i'm getting error.
Traceback (most recent call last):
File "spark.py", line 7, in <module>
from textblob_aptagger import PerceptronTagger
File "/usr/local/lib/python2.7/dist-packages/textblob_aptagger/__init__.py", line 8, in <module>
from textblob_aptagger.taggers import PerceptronTagger
File "/usr/local/lib/python2.7/dist-packages/textblob_aptagger/taggers.py", line 10, in <module>
from textblob.packages import nltk
ImportError: No module named packages
Here's a pastebin to my code and imports..
Same error has been posted on github here. Use this instead to install textblob:
$ pip install -U git+https://github.com/sloria/textblob-aptagger.git#dev
Also, you should change from text.blob import TextBlob as tbto from textblob...
Works for me..

Installation of nltk and scikit-learn

I have been trying to install and use scikit-learn and nltk. However, I get the following error while importing anything:
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python2.7/site-packages/sklearn/init.py", line 57, in
from .base import clone
File "/usr/local/lib/python2.7/site-packages/sklearn/base.py", line 11, in
from .utils.fixes import signature
File "/usr/local/lib/python2.7/site-packages/sklearn/utils/init.py", line 10, in
from .murmurhash import murmurhash3_32
File "numpy.pxd", line 155, in init sklearn.utils.murmurhash (sklearn/utils/murmurhash.c:5029)
ValueError: numpy.dtype has the wrong size, try recompiling
I did a pip uninstall numpy followed by a pip install numpy and also a pip uninstall scikit-learn and again reinstalled it. But the error persists.
I met the same problem today. Now I have solved it.
Because I have installed numPy manually, and I use the command "pip" to install the else package.
Solve way:
find the old version of numPy.
You can import numPy and print the path of it.
delete the folder.
use pip to install again.

Problems installing gnuplot on mac os x

I'm getting this error after downloading the .zip file:
Traceback (most recent call last):
File "setup.py", line 15, in <module>
from __init__ import __version__
File "/Users/me/Downloads/gnuplot-py-1.8/__init__.py", line 164, in <module>
from gp import GnuplotOpts, GnuplotProcess, test_persist
ImportError: cannot import name GnuplotOpts
I have gnuplot installed on my machine, if I type gnuplot on the terminal the gnuplot terminal pops up. I'm trying to call it with python and it's saying it's not installed. This may be a path issue, but I'm just trying to make sure EVERYTHING needed is installed. (Path recommendations would be appreciated too)
Mac 10.7 Lion
So guys, the issue was solved by doing :
pip install http://prdownloads.sourceforge.net/gnuplot-py/gnuplot-py-1.8.tar.gz?download
and importing Gnuplot.

Can't import audiolab in python

I installed audiolab from this source:
http://www.lfd.uci.edu/~gohlke/pythonlibs/#scikits.audiolab
Those are the only windows binaries for python 2.7 I was able to find.
When I call from scikits import audiolab I get the following error:
Traceback (most recent call last):
File "<pyshell#5>", line 1, in <module>
from scikits import audiolab
File "C:\Python27\lib\site-packages\scikits\audiolab\__init__.py", line 34, in <module>
from pysndfile.matapi import *
File "C:\Python27\lib\site-packages\scikits\audiolab\pysndfile\matapi.py", line 145, in <module>
Format('wav', 'pcm16').file_format)
File "_sndfile.pyx", line 170, in scikits.audiolab.pysndfile._sndfile.Format.__init__ (scikits\audiolab\pysndfile\_sndfile.c:1429)
NameError: _SNDFILE_FILE_FORMAT
Is there a way to fix it? If not what should I use for audio processing instead? (Audiolab seemed to be the best alternative among audiotools and pyaudio)
EDIT:
After replacing libsndfile-1.dll, I have this new error:
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
from scikits import audiolab
File "C:\Python27\lib\site-packages\scikits\audiolab\__init__.py", line 25, in <module>
from pysndfile import formatinfo, sndfile
File "C:\Python27\lib\site-packages\scikits\audiolab\pysndfile\__init__.py", line 1, in <module>
from _sndfile import Sndfile, Format, available_file_formats, \
File "numpy.pxd", line 30, in scikits.audiolab.pysndfile._sndfile (scikits\audiolab\pysndfile\_sndfile.c:9632)
ValueError: numpy.dtype does not appear to be the correct type object
Note: numpy is installed.
As far as I can tell you need to install libsndfile-1.0.25 as is mentioned right where you downloaded the binary
Scikits.audiolab is a package for audio file IO using numpy arrays. Linked against libsndfile-1.0.25.
You can download an installer from here. You may need to reinstall the scikits.audiolab distribution after you install libsndfile (although honestly, I'm not sure).
However, if this seems a lot of effort, it might be easier for you to install Python 2.6 and install audiolab from PyPi as scikits docs suggest. The PyPi version of scikits.audiolab is statically linked to libsndfile so you will not need to install it on your own.
I had the same problem on Mac OS. It's possible that you updated or installed a new version of python/numpy after you install audiolab. What I did is uninstall scikits.audiolab and reinstall it again, which got rid of this error
I had the same problem on Ubuntu 10.04.4 LTS. The reason was that the installed version of audiolab was for python2.5, but in the meantime with Ubuntu 10.04.4 LTS python was upgradee to version 2.6. After a new install of audiolab (wich grabbed the correct version) all's working fine.
All you need to do is to install libsndfile would have worked also.
brew install libsndfile

Categories