I'm new to both python and OSX, so if i'm not understanding super basic stuff please forgive me.
I'm using python 2.7.12 on a fresh install from Homebrew. I also used Homebrew to install ipython, ffmpeg and libav (installs avconv, which I believe is required for what i'm trying to do).
I've used pip to install Scipy, numpy (which I think comes with scipy anyway?) and matplotlib
I'm running El Capitan v10.11.6
Background (for some context):
I'm running some hydrodynamic simulations that output a bunch of binary files. I wan't to stitch them together to create a movie. Lucky for me, one of my colleagues has already written a tidy little python script to do so (which he wrote in ipython).
Problem:
When trying to run
import matplotlib.animation
The script just hangs, and matplotlib animation never gets imported. I've tried changing the backend via
import matplotlib
matplotlib.use('tkagg')
import matplotlib.animaton
I've tried various backends that I got by running code from List of all available matplotlib backends
I have also tried import matplotlib.pyplot hangs (updating fc-lists)
Lastly, and i'm not sure if this is helpful, but leaving ipython trying to import matplot.animation for about 10 minutes, and then terminating it outputs the following
In [3]: import matplotlib.animation
^C---------------------------------------------------------------------------
KeyboardInterrupt Traceback (most recent call last)
<ipython-input-3-64e90e455a86> in <module>()
----> 1 import matplotlib.animation
/usr/local/lib/python2.7/site-packages/matplotlib/animation.py in <module>()
589
590 #writers.register('imagemagick')
--> 591 class ImageMagickWriter(MovieWriter, ImageMagickBase):
592 def _args(self):
593 return ([self.bin_path(),
/usr/local/lib/python2.7/site-packages/matplotlib/animation.py in wrapper(writerClass)
73 def register(self, name):
74 def wrapper(writerClass):
---> 75 if writerClass.isAvailable():
76 self.avail[name] = writerClass
77 return writerClass
/usr/local/lib/python2.7/site-packages/matplotlib/animation.py in isAvailable(cls)
284 stderr=subprocess.PIPE,
285 creationflags=subprocess_creation_flags)
--> 286 p.communicate()
287 return True
288 except OSError:
/usr/local/Cellar/python/2.7.12_2/Frameworks/Python.framework/Versions/2.7/ lib/python2.7/subprocess.pyc in communicate(self, input)
798 return (stdout, stderr)
799
--> 800 return self._communicate(input)
801
802
/usr/local/Cellar/python/2.7.12_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.pyc in _communicate(self, input)
1417 stdout, stderr = self._communicate_with_poll(input)
1418 else:
-> 1419 stdout, stderr = self._communicate_with_select(input)
1420
1421 # All data exchanged. Translate lists into strings.
/usr/local/Cellar/python/2.7.12_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.pyc in _communicate_with_select(self, input)
1518 while read_set or write_set:
1519 try:
-> 1520 rlist, wlist, xlist = select.select(read_set, write_set, [])
1521 except select.error, e:
1522 if e.args[0] == errno.EINTR:
KeyboardInterrupt:
If you give any of this a second thought, even if you aren't able to help, thank you very much!
Do you have more than one version of Python installed? I would check your python path. Make sure matplotlib is in 2.7 in this case.
This might be relevant too -- import matplotlib.pyplot hangs
Related
I would like to check the number if issues in a given sentence.
my code is
import language_tool_python
tl = language_tool_python.LanguageTool('en-US')
txt = "good mooorning sirr and medam my namee anderen i am from amerecia !"
m = tl.check(txt)
len(m)
Instead of returning the number i am getting error message as shown below.
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-1-1c4c9134d6f4> in <module>
1 import language_tool_python
----> 2 tool = language_tool_python.LanguageTool('en-US')
3
4 text = "Your the best but their are allso good !"
5 matches = tool.check(text)
E:\Anaconda\lib\site-packages\language_tool_python\server.py in __init__(self, language, motherTongue, remote_server, newSpellings, new_spellings_persist)
43 self._update_remote_server_config(self._url)
44 elif not self._server_is_alive():
---> 45 self._start_server_on_free_port()
46 if language is None:
47 try:
E:\Anaconda\lib\site-packages\language_tool_python\server.py in _start_server_on_free_port(self)
212 self._url = 'http://{}:{}/v2/'.format(self._HOST, self._port)
213 try:
--> 214 self._start_local_server()
215 break
216 except ServerError:
E:\Anaconda\lib\site-packages\language_tool_python\server.py in _start_local_server(self)
222 def _start_local_server(self):
223 # Before starting local server, download language tool if needed.
--> 224 download_lt()
225 err = None
226 try:
E:\Anaconda\lib\site-packages\language_tool_python\download_lt.py in download_lt(update)
142 ]
143
--> 144 confirm_java_compatibility()
145 version = LATEST_VERSION
146 filename = FILENAME.format(version=version)
E:\Anaconda\lib\site-packages\language_tool_python\download_lt.py in confirm_java_compatibility()
73 # found because of a PATHEXT-related issue
74 # (https://bugs.python.org/issue2200).
---> 75 raise ModuleNotFoundError('No java install detected. Please install java to use language-tool-python.')
76
77 output = subprocess.check_output([java_path, '-version'],
ModuleNotFoundError: No java install detected. Please install java to use language-tool-python.
When I run the code I get no java install detected
How to solve this issue?
I think this is not an issue with the Code itself when I run the code you provided
import language_tool_python
tl = language_tool_python.LanguageTool('en-US')
txt = "good mooorning sirr and medam my namee anderen i am from amerecia !"
m = tl.check(txt)
len(m)
I get as result a number in this case
OUT: 8
In the Documentation of the language-tool-python is written:
By default, language_tool_python will download a LanguageTool server .jar and run that in the background to detect grammar errors locally. However, LanguageTool also offers a Public HTTP Proofreading API that is supported as well. Follow the link for rate-limiting details. (Running locally won't have the same restrictions.)
So You will need Java (JRE and SKD). Also it's Written in the Requirements of the library:
Prerequisites
Python 3.5+
LanguageTool (Java 8.0 or higher)
The installation process should take care of downloading LanguageTool (it may take a few minutes). Otherwise, you can manually download LanguageTool-stable.zip and unzip it into where the language_tool_python package resides.
Source:
https://pypi.org/project/language-tool-python/
Python 2.7 - JavaError when using grammar-check 1.3.1 library
I Hope I could help.
Previously, I was working on a Jupyter notebook project on a mac running Python 3.7.
Today, when I wanted to load the notebook's %pylab inline machinery, I received the error:
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-1-a6e0d37a4680> in <module>
----> 1 get_ipython().run_line_magic('pylab', 'inline')
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/IPython/core/interactiveshell.py in run_line_magic(self, magic_name, line, _stack_depth)
2283 kwargs['local_ns'] = sys._getframe(stack_depth).f_locals
2284 with self.builtin_trap:
-> 2285 result = fn(*args,**kwargs)
2286 return result
2287
<decorator-gen-108> in pylab(self, line)
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/IPython/core/magic.py in <lambda>(f, *a, **k)
185 # but it's overkill for just that one bit of state.
186 def magic_deco(arg):
--> 187 call = lambda f, *a, **k: f(*a, **k)
188
189 if callable(arg):
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site- packages/IPython/core/magics/pylab.py in pylab(self, line)
153 import_all = not args.no_import_all
154
--> 155 gui, backend, clobbered = self.shell.enable_pylab(args.gui, import_all=import_all)
156 self._show_matplotlib_backend(args.gui, backend)
157 print ("Populating the interactive namespace from numpy and matplotlib")
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/IPython/core/interactiveshell.py in enable_pylab(self, gui, import_all, welcome_message)
3390 from IPython.core.pylabtools import import_pylab
3391
-> 3392 gui, backend = self.enable_matplotlib(gui)
3393
3394 # We want to prevent the loading of pylab to pollute the user's
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/IPython/core/interactiveshell.py in enable_matplotlib(self, gui)
3339 """
3340 from IPython.core import pylabtools as pt
-> 3341 gui, backend = pt.find_gui_and_backend(gui, self.pylab_gui_select)
3342
3343 if gui != 'inline':
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/IPython/core/pylabtools.py in find_gui_and_backend(gui, gui_select)
274 """
275
--> 276 import matplotlib
277
278 if gui and gui != 'auto':
ModuleNotFoundError: No module named 'matplotlib'
I've tried looking for solutions online.
I have removed Python 3.6, reinstalled brew from scratch, reinstalled jupyter from scratch using the terminal but to no solution.
Is there a solution?
Don't use %pylab, it is deprecated. Use either:
%matplotlib inline
or %matplotlib notebook
After I installed the package Iris with conda install -c scitools iris,
Whether using Ipython console or Jupyter notebook, the iris was always failed to import. The error subroutine shows like:
---------------------------------------------------------------------------
CalledProcessError Traceback (most recent call last)
<ipython-input-1-005053b25f37> in <module>()
----> 1 import iris
/Users/TEST/anaconda/lib/python2.7/site-packages/iris/__init__.pyc in <module>()
110 import iris.cube
111 import iris._constraints
--> 112 import iris.fileformats
113 import iris.io
114
/Users/TEST/anaconda/lib/python2.7/site-packages/iris/fileformats/__init__.py in <module>()
23 from six.moves import (filter, input, map, range, zip) # noqa
24
---> 25 from iris.io.format_picker import (FileExtension, FormatAgent,
26 FormatSpecification, MagicNumber,
27 UriProtocol, LeadingLine)
/Users/TEST/anaconda/lib/python2.7/site-packages/iris/io/__init__.py in <module>()
31
32 import iris.fileformats
---> 33 import iris.fileformats.dot
34 import iris.cube
35 import iris.exceptions
/Users/TEST/anaconda/lib/python2.7/site-packages/iris/fileformats/dot.py in <module>()
41 # Check PATH
42 subprocess.check_output([_DOT_EXECUTABLE_PATH, '-V'],
---> 43 stderr=subprocess.STDOUT)
44 except OSError:
45 _DOT_EXECUTABLE_PATH = None
/Users/TEST/anaconda/lib/python2.7/subprocess.pyc in check_output(*popenargs, **kwargs)
571 if cmd is None:
572 cmd = popenargs[0]
--> 573 raise CalledProcessError(retcode, cmd, output=output)
574 return output
575
CalledProcessError: Command '['dot', '-V']' returned non-zero exit status -5
I raised a similar issue on the iris GitHub tracker (https://github.com/SciTools/iris/issues/1899). Essentially, as much as I believe it was intended to be optional, the way it has been implemented I think Iris actually requires a dot installation. With conda, that should look like:
conda install graphviz
HTH
In my particular case, this error was resolved by installing GraphViz.
I believe the root case of this issue is that the graphiz python bindings cannot find the command line utilities required to render the output into some form, e.g. .pdf, .svg or .png.
I have the Enthought Canopy installed on my Ubuntu 14.04. I'm trying to run sample matplotlib programs (from the library's website). Every attempt of running the program makes the Canopy's command prompt display following message:
TypeError Traceback (most recent call last)
/home/guras/Canopy/appdata/canopy-1.4.1.1975.rh5-x86_64/lib/python2.7/site-packages/IPython/utils/py3compat.pyc in execfile(fname, *where)
202 else:
203 filename = fname
--> 204 __builtin__.execfile(filename, *where)
/home/guras/Python programy/pierwszy.py in <module>()
4 This example uses the Fahrenheit and Celsius scales.
5 """
----> 6 import matplotlib.pyplot as plt
7 import numpy as np
8
/home/guras/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/matplotlib/pyplot.py in <module>()
26 import matplotlib
27 import matplotlib.colorbar
---> 28 from matplotlib import style
29 from matplotlib import _pylab_helpers, interactive
30 from matplotlib.cbook import dedent, silent_list, is_string_like, is_numlike
/home/guras/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/matplotlib/style/__init__.py in <module>()
1 from __future__ import absolute_import
2
----> 3 from .core import use, context, available, library, reload_library
/home/guras/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/matplotlib/style/core.py in <module>()
147 # Load style library
148 # ==================
--> 149 _base_library = load_base_library()
150
151 library = None
/home/guras/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/matplotlib/style/core.py in load_base_library()
92 """Load style library defined in this package."""
93 library = dict()
---> 94 library.update(read_style_directory(BASE_LIBRARY_PATH))
95 return library
96
/home/guras/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/matplotlib/style/core.py in read_style_directory(style_dir)
125 styles = dict()
126 for path, name in iter_style_files(style_dir):
--> 127 styles[name] = rc_params_from_file(path, use_default_template=False)
128 return styles
129
TypeError: **rc_params_from_file() got an unexpected keyword argument 'use_default_template'**
Any ideas how to fix it?
The use_default_template keyword parameter was added to the rc_params_from_file function in matplotlib version 1.4.0rc1.
Most likely, your version of matplotlib is older than 1.4.0rc1 and needs to be upgraded.
If you have more than one installation of matplotlib installed, you'll need to make sure the directory containing the newer version is listed earlier than the older version in sys.path, or perhaps, simply delete the older version of matplotlib.
Use the Canopy Package Manager to update matplotlib to the latest version.
I am using nltk (installed and works fine in IDLE) for a project in Python (2.7.4) which runs perfectly fine on IDLE, but using the same code in xampp or wamp (cgi-bin), everything related to 'nltk' doesn't works and this is the error shown by adding these lines
import cgitb
cgitb.enable()
The errors are in lines are marked by '=>' and details are enclosed within ** and **. I've tried printing 'sys.path' after importing os, which shows the 'site-packages' directory in which 'nltk' resides. I even copied and pasted this folder into 'C:\Python27\' but still the same errors. Things other than nltk works as desired.
<type 'exceptions.ValueError'> Python 2.7.4: C:\python27\python.exe
Wed May 14 16:13:34 2014
A problem occurred in a Python script. Here is the sequence of function calls
leading up to the error, in the order they occurred.
C:\xampp\cgi-bin\Major\project.py in ()
=> 73 import nltk
**nltk undefined**
C:\python27\nltk\__init__.py in ()
159 import cluster; from cluster import *
160
=> 161 from downloader import download, download_shell
162 try:
163 import Tkinter
**downloader undefined, download undefined, download_shell undefined**
C:\python27\nltk\downloader.py in ()
2199
2200 # Aliases
=> 2201 _downloader = Downloader()
2202 download = _downloader.download
2203 def download_shell(): DownloaderShell(_downloader).run()
**_downloader undefined, Downloader = None**
C:\python27\nltk\downloader.py in __init__(self=<nltk.downloader.Downl
oader object>, server_index_url=None, download_dir=None)
425 # decide where we're going to save things to.
426 if self._download_dir is None:
=> 427 self._download_dir = self.default_download_dir()
428
429 #/////////////////////////////////////////////////////////////////
**self = <nltk.downloader.Downloader object>, self._download_dir = None,
self.default_download_dir = <bound method Downloader.default_download_dir of
<nltk.downloader.Downloader object>>**
C:\python27\nltk\downloader.py in default_download_dir(self=<nltk.downloa
der.Downloader object>)
926 homedir = os.path.expanduser('~/')
927 if homedir == '~/':
=> 928 raise ValueError("Could not find a default
download directory")
929
930 # append "nltk_data" to the home directory
**<pre>builtin ValueError = < type 'exceptions.ValueError' > <pre/>**
<type 'exceptions.ValueError'>: Could not find a default download directory
args = ('Could not find a default download directory',)
message = 'Could not find a default download directory'