Related
I am having below data frame and wanted to save the data frame as a CSV file in the Azure Data lake. My data frame is called 'df'. I am using Azure Synpase Notebook
df.to_csv('abfss://jobsdata#strxxxuei.dfs.core.windows.net/Jobs_newdata/data.csv', sep=',', encoding='utf-8', index=False)
Getting the below error message when I tried to run the above code,
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
/tmp/ipykernel_6713/3472604753.py in <module>
----> 1 df.to_csv('abfss://jobsdata#strxxxuei.dfs.core.windows.net/Jobs_newdata/jobs.csv', sep=',', encoding='utf-8', index=False)
~/cluster-env/clonedenv/lib/python3.8/site-packages/pandas/core/generic.py in to_csv(self, path_or_buf, sep, na_rep, float_format, columns, header, index, index_label, mode, encoding, compression, quoting, quotechar, line_terminator, chunksize, date_format, doublequote, escapechar, decimal, errors, storage_options)
3385 )
3386
-> 3387 return DataFrameRenderer(formatter).to_csv(
3388 path_or_buf,
3389 line_terminator=line_terminator,
~/cluster-env/clonedenv/lib/python3.8/site-packages/pandas/io/formats/format.py in to_csv(self, path_or_buf, encoding, sep, columns, index_label, mode, compression, quoting, quotechar, line_terminator, chunksize, date_format, doublequote, escapechar, errors, storage_options)
1081 formatter=self.fmt,
1082 )
-> 1083 csv_formatter.save()
1084
1085 if created_buffer:
~/cluster-env/clonedenv/lib/python3.8/site-packages/pandas/io/formats/csvs.py in save(self)
226 """
227 # apply compression and byte/text conversion
--> 228 with get_handle(
229 self.filepath_or_buffer,
230 self.mode,
~/cluster-env/clonedenv/lib/python3.8/site-packages/pandas/io/common.py in get_handle(path_or_buf, mode, encoding, compression, memory_map, is_text, errors, storage_options)
556
557 # open URLs
--> 558 ioargs = _get_filepath_or_buffer(
559 path_or_buf,
560 encoding=encoding,
~/cluster-env/clonedenv/lib/python3.8/site-packages/pandas/io/common.py in _get_filepath_or_buffer(filepath_or_buffer, encoding, compression, mode, storage_options)
331
332 try:
--> 333 file_obj = fsspec.open(
334 filepath_or_buffer, mode=fsspec_mode, **(storage_options or {})
335 ).open()
~/cluster-env/clonedenv/lib/python3.8/site-packages/fsspec/core.py in open(urlpath, mode, compression, encoding, errors, protocol, newline, **kwargs)
427 ``OpenFile`` object.
428 """
--> 429 return open_files(
430 urlpath=[urlpath],
431 mode=mode,
~/cluster-env/clonedenv/lib/python3.8/site-packages/fsspec/core.py in open_files(urlpath, mode, compression, encoding, errors, name_function, num, protocol, newline, auto_mkdir, expand, **kwargs)
279 be used as a single context
280 """
--> 281 fs, fs_token, paths = get_fs_token_paths(
282 urlpath,
283 mode,
~/cluster-env/clonedenv/lib/python3.8/site-packages/fsspec/core.py in get_fs_token_paths(urlpath, mode, num, name_function, storage_options, protocol, expand)
597 "share the same protocol"
598 )
--> 599 cls = get_filesystem_class(protocol)
600 optionss = list(map(cls._get_kwargs_from_urls, urlpath))
601 paths = [cls._strip_protocol(u) for u in urlpath]
~/cluster-env/clonedenv/lib/python3.8/site-packages/fsspec/registry.py in get_filesystem_class(protocol)
209 bit = known_implementations[protocol]
210 try:
--> 211 register_implementation(protocol, _import_class(bit["class"]))
212 except ImportError as e:
213 raise ImportError(bit["err"]) from e
~/cluster-env/clonedenv/lib/python3.8/site-packages/fsspec/registry.py in _import_class(cls, minv)
232 else:
233 mod, name = cls.rsplit(".", 1)
--> 234 mod = importlib.import_module(mod)
235 return getattr(mod, name)
236
~/cluster-env/clonedenv/lib/python3.8/importlib/__init__.py in import_module(name, package)
125 break
126 level += 1
--> 127 return _bootstrap._gcd_import(name[level:], package, level)
128
129
~/cluster-env/clonedenv/lib/python3.8/importlib/_bootstrap.py in _gcd_import(name, package, level)
~/cluster-env/clonedenv/lib/python3.8/importlib/_bootstrap.py in _find_and_load(name, import_)
~/cluster-env/clonedenv/lib/python3.8/importlib/_bootstrap.py in _find_and_load_unlocked(name, import_)
~/cluster-env/clonedenv/lib/python3.8/importlib/_bootstrap.py in _load_unlocked(spec)
~/cluster-env/clonedenv/lib/python3.8/importlib/_bootstrap_external.py in exec_module(self, module)
~/cluster-env/clonedenv/lib/python3.8/importlib/_bootstrap.py in _call_with_frames_removed(f, *args, **kwds)
~/cluster-env/clonedenv/lib/python3.8/site-packages/fsspec_wrapper/__init__.py in <module>
----> 1 from .core import (
2 AzureBlobFileSystem
3 )
4
5 __all__ = [
~/cluster-env/clonedenv/lib/python3.8/site-packages/fsspec_wrapper/core.py in <module>
3 from .utils import logger as synapseml_pandas_logger
4 from .utils.common import SynapseCredential
----> 5 import adlfs
6 import time
7 import re
~/cluster-env/clonedenv/lib/python3.8/site-packages/adlfs/__init__.py in <module>
----> 1 from .spec import AzureDatalakeFileSystem
2 from .spec import AzureBlobFileSystem, AzureBlobFile
3 from ._version import get_versions
4
5 __all__ = ["AzureBlobFileSystem", "AzureBlobFile", "AzureDatalakeFileSystem"]
~/cluster-env/clonedenv/lib/python3.8/site-packages/adlfs/spec.py in <module>
16 ResourceExistsError,
17 )
---> 18 from azure.storage.blob._shared.base_client import create_configuration
19 from azure.datalake.store import AzureDLFileSystem, lib
20 from azure.datalake.store.core import AzureDLFile, AzureDLPath
~/cluster-env/clonedenv/lib/python3.8/site-packages/azure/storage/blob/__init__.py in <module>
8 from typing import Union, Iterable, AnyStr, IO, Any, Dict # pylint: disable=unused-import
9 from ._version import VERSION
---> 10 from ._blob_client import BlobClient
11 from ._container_client import ContainerClient
12 from ._blob_service_client import BlobServiceClient
~/cluster-env/clonedenv/lib/python3.8/site-packages/azure/storage/blob/_blob_client.py in <module>
24
25 from ._shared import encode_base64
---> 26 from ._shared.base_client import StorageAccountHostsMixin, parse_connection_str, parse_query, TransportWrapper
27 from ._shared.encryption import generate_blob_encryption_data
28 from ._shared.uploads import IterStreamer
~/cluster-env/clonedenv/lib/python3.8/site-packages/azure/storage/blob/_shared/base_client.py in <module>
38 from .constants import STORAGE_OAUTH_SCOPE, SERVICE_HOST_BASE, CONNECTION_TIMEOUT, READ_TIMEOUT
39 from .models import LocationMode
---> 40 from .authentication import SharedKeyCredentialPolicy
41 from .shared_access_signature import QueryStringConstants
42 from .request_handlers import serialize_batch_body, _get_batch_request_delimiter
~/cluster-env/clonedenv/lib/python3.8/site-packages/azure/storage/blob/_shared/authentication.py in <module>
20
21 try:
---> 22 from azure.core.pipeline.transport import AioHttpTransport
23 except ImportError:
24 AioHttpTransport = None
~/cluster-env/clonedenv/lib/python3.8/importlib/_bootstrap.py in _handle_fromlist(module, fromlist, import_, recursive)
~/cluster-env/clonedenv/lib/python3.8/site-packages/azure/core/pipeline/transport/__init__.py in __getattr__(name)
66 if name == 'AioHttpTransport':
67 try:
---> 68 from ._aiohttp import AioHttpTransport
69 return AioHttpTransport
70 except ImportError:
~/cluster-env/clonedenv/lib/python3.8/site-packages/azure/core/pipeline/transport/_aiohttp.py in <module>
33 import asyncio
34 import codecs
---> 35 import aiohttp
36 from multidict import CIMultiDict
37
~/cluster-env/clonedenv/lib/python3.8/site-packages/aiohttp/__init__.py in <module>
4
5 from . import hdrs as hdrs
----> 6 from .client import (
7 BaseConnector as BaseConnector,
8 ClientConnectionError as ClientConnectionError,
~/cluster-env/clonedenv/lib/python3.8/site-packages/aiohttp/client.py in <module>
33 from yarl import URL
34
---> 35 from . import hdrs, http, payload
36 from .abc import AbstractCookieJar
37 from .client_exceptions import (
~/cluster-env/clonedenv/lib/python3.8/site-packages/aiohttp/http.py in <module>
5 from . import __version__
6 from .http_exceptions import HttpProcessingError as HttpProcessingError
----> 7 from .http_parser import (
8 HeadersParser as HeadersParser,
9 HttpParser as HttpParser,
~/cluster-env/clonedenv/lib/python3.8/site-packages/aiohttp/http_parser.py in <module>
13 from . import hdrs
14 from .base_protocol import BaseProtocol
---> 15 from .helpers import NO_EXTENSIONS, BaseTimerContext
16 from .http_exceptions import (
17 BadStatusLine,
~/cluster-env/clonedenv/lib/python3.8/site-packages/aiohttp/helpers.py in <module>
665
666
--> 667 class CeilTimeout(async_timeout.timeout):
668 def __enter__(self) -> async_timeout.timeout:
669 if self._timeout is not None:
TypeError: function() argument 'code' must be code, not str
I am getting the above error message, not sure how to rectify it.
Can anyone advise what is the issue in my code?
This could be due to invalid permission to access the container or you may not have write permissions to the container.
I have repro’d with your code and was able to write the data to CSV successfully.
df.to_csv('abfss://<container name>#<storage account name>.dfs.core.windows.net/source/sample2.csv', sep=',', encoding='utf-8', index=False)
Output:
I was trying to plot a graphic with matplotlib in Jupyter and then with only the 'pylab inline' the following error shows up. I'm working with python 3.x and anaconda in a macbook. I found similar trends (for example this) with some potential solutions but they didn't work. I have tried everything but nothing works. I would really appreciate any help.
My code:
%pylab inline
which produces the following error:
---------------------------------------------------------------------------
FileNotFoundError Traceback (most recent call last)
//anaconda/lib/python3.6/site-packages/matplotlib/font_manager.py in <module>()
1429 try:
-> 1430 fontManager = pickle_load(_fmcache)
1431 if (not hasattr(fontManager, '_version') or
//anaconda/lib/python3.6/site-packages/matplotlib/font_manager.py in pickle_load(filename)
965 """
--> 966 with open(filename, 'rb') as fh:
967 data = pickle.load(fh)
FileNotFoundError: [Errno 2] No such file or directory: '/Users/sebasg167/.matplotlib/fontList.py3k.cache'
During handling of the above exception, another exception occurred:
TypeError Traceback (most recent call last)
<ipython-input-2-d4543581fa9d> in <module>()
----> 1 get_ipython().magic('pylab inline')
//anaconda/lib/python3.6/site-packages/IPython/core/interactiveshell.py in magic(self, arg_s)
2156 magic_name, _, magic_arg_s = arg_s.partition(' ')
2157 magic_name = magic_name.lstrip(prefilter.ESC_MAGIC)
-> 2158 return self.run_line_magic(magic_name, magic_arg_s)
2159
2160 #-------------------------------------------------------------------------
//anaconda/lib/python3.6/site-packages/IPython/core/interactiveshell.py in run_line_magic(self, magic_name, line)
2077 kwargs['local_ns'] = sys._getframe(stack_depth).f_locals
2078 with self.builtin_trap:
-> 2079 result = fn(*args,**kwargs)
2080 return result
2081
<decorator-gen-105> in pylab(self, line)
//anaconda/lib/python3.6/site-packages/IPython/core/magic.py in <lambda>(f, *a, **k)
186 # but it's overkill for just that one bit of state.
187 def magic_deco(arg):
--> 188 call = lambda f, *a, **k: f(*a, **k)
189
190 if callable(arg):
//anaconda/lib/python3.6/site-packages/IPython/core/magics/pylab.py in pylab(self, line)
154 import_all = not args.no_import_all
155
--> 156 gui, backend, clobbered = self.shell.enable_pylab(args.gui, import_all=import_all)
157 self._show_matplotlib_backend(args.gui, backend)
158 print ("Populating the interactive namespace from numpy and matplotlib")
//anaconda/lib/python3.6/site-packages/IPython/core/interactiveshell.py in enable_pylab(self, gui, import_all, welcome_message)
2984 from IPython.core.pylabtools import import_pylab
2985
-> 2986 gui, backend = self.enable_matplotlib(gui)
2987
2988 # We want to prevent the loading of pylab to pollute the user's
//anaconda/lib/python3.6/site-packages/IPython/core/interactiveshell.py in enable_matplotlib(self, gui)
2945 gui, backend = pt.find_gui_and_backend(self.pylab_gui_select)
2946
-> 2947 pt.activate_matplotlib(backend)
2948 pt.configure_inline_support(self, backend)
2949
//anaconda/lib/python3.6/site-packages/IPython/core/pylabtools.py in activate_matplotlib(backend)
292 matplotlib.rcParams['backend'] = backend
293
--> 294 import matplotlib.pyplot
295 matplotlib.pyplot.switch_backend(backend)
296
//anaconda/lib/python3.6/site-packages/matplotlib/pyplot.py in <module>()
27 from cycler import cycler
28 import matplotlib
---> 29 import matplotlib.colorbar
30 from matplotlib import style
31 from matplotlib import _pylab_helpers, interactive
//anaconda/lib/python3.6/site-packages/matplotlib/colorbar.py in <module>()
34 import matplotlib.collections as collections
35 import matplotlib.colors as colors
---> 36 import matplotlib.contour as contour
37 import matplotlib.cm as cm
38 import matplotlib.gridspec as gridspec
//anaconda/lib/python3.6/site-packages/matplotlib/contour.py in <module>()
20 import matplotlib.colors as colors
21 import matplotlib.collections as mcoll
---> 22 import matplotlib.font_manager as font_manager
23 import matplotlib.text as text
24 import matplotlib.cbook as cbook
//anaconda/lib/python3.6/site-packages/matplotlib/font_manager.py in <module>()
1438 raise
1439 except:
-> 1440 _rebuild()
1441 else:
1442 _rebuild()
//anaconda/lib/python3.6/site-packages/matplotlib/font_manager.py in _rebuild()
1417 global fontManager
1418
-> 1419 fontManager = FontManager()
1420
1421 if _fmcache:
//anaconda/lib/python3.6/site-packages/matplotlib/font_manager.py in __init__(self, size, weight)
1071 self.afmfiles = findSystemFonts(paths, fontext='afm') + \
1072 findSystemFonts(fontext='afm')
-> 1073 self.afmlist = createFontList(self.afmfiles, fontext='afm')
1074 if len(self.afmfiles):
1075 self.defaultFont['afm'] = self.afmfiles[0]
//anaconda/lib/python3.6/site-packages/matplotlib/font_manager.py in createFontList(fontfiles, fontext)
589 continue
590 try:
--> 591 prop = afmFontProperty(fpath, font)
592 except KeyError:
593 continue
//anaconda/lib/python3.6/site-packages/matplotlib/font_manager.py in afmFontProperty(fontpath, font)
498 """
499
--> 500 name = font.get_familyname()
501 fontname = font.get_fontname().lower()
502
//anaconda/lib/python3.6/site-packages/matplotlib/afm.py in get_familyname(self)
523 extras = (br'(?i)([ -](regular|plain|italic|oblique|bold|semibold|'
524 br'light|ultralight|extra|condensed))+$')
--> 525 return re.sub(extras, '', name)
526
527 #property
//anaconda/lib/python3.6/re.py in sub(pattern, repl, string, count, flags)
189 a callable, it's passed the match object and must return
190 a replacement string to be used."""
--> 191 return _compile(pattern, flags).sub(repl, string, count)
192
193 def subn(pattern, repl, string, count=0, flags=0):
TypeError: cannot use a bytes pattern on a string-like object
You must find this file :
font_manager.py
in my case : C:\Users\gustavo\Anaconda3\Lib\site-packages\matplotlib\ font_manager.py
and FIND def win32InstalledFonts(directory=None, fontext='ttf')
and replace
by :
def win32InstalledFonts(directory=None, fontext='ttf'):
"""
Search for fonts in the specified font directory, or use the
system directories if none given. A list of TrueType font
filenames are returned by default, or AFM fonts if fontext ==
'afm'.
"""
from six.moves import winreg
if directory is None:
directory = win32FontDirectory()
fontext = get_fontext_synonyms(fontext)
key, items = None, {}
for fontdir in MSFontDirectories:
try:
local = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, fontdir)
except OSError:
continue
if not local:
return list_fonts(directory, fontext)
try:
for j in range(winreg.QueryInfoKey(local)[1]):
try:
key, direc, any = winreg.EnumValue(local, j)
if not is_string_like(direc):
continue
if not os.path.dirname(direc):
direc = os.path.join(directory, direc)
direc = direc.split('\0', 1)[0]
if os.path.splitext(direc)[1][1:] in fontext:
items[direc] = 1
except EnvironmentError:
continue
except WindowsError:
continue
except MemoryError:
continue
return list(six.iterkeys(items))
finally:
winreg.CloseKey(local)
return None
This question already has answers here:
IPython Notebook locale error [duplicate]
(4 answers)
Closed 6 years ago.
I have installed pandas through conda install pandas and still receiving this error while importing the pandas library through ipython jupyter notebook.
I have also tried to check the version mismatch through
print ('version:' + np.__version__)
and have traced the path to the sys.executable directory from this
sys.executable
for x in sys.path: print (x)
and have the correct path to data directory.
from jupyter_core.paths import jupyter_data_dir
print(jupyter_data_dir())
import pandas as pd
ValueError Traceback (most recent call last)
<ipython-input-1-af55e7023913> in <module>()
----> 1 import pandas as pd
/Users/amitanshu/anaconda/lib/python3.5/site-packages/pandas/__init__.py in <module>()
42 import pandas.core.config_init
43
---> 44 from pandas.core.api import *
45 from pandas.sparse.api import *
46 from pandas.stats.api import *
/Users/amitanshu/anaconda/lib/python3.5/site-packages/pandas/core/api.py in <module>()
7 from pandas.core.common import isnull, notnull
8 from pandas.core.categorical import Categorical
----> 9 from pandas.core.groupby import Grouper
10 from pandas.core.format import set_eng_float_format
11 from pandas.core.index import Index, CategoricalIndex, Int64Index, Float64Index, MultiIndex
/Users/amitanshu/anaconda/lib/python3.5/site-packages/pandas/core/groupby.py in <module>()
15 from pandas.core.base import PandasObject
16 from pandas.core.categorical import Categorical
---> 17 from pandas.core.frame import DataFrame
18 from pandas.core.generic import NDFrame
19 from pandas.core.index import Index, MultiIndex, CategoricalIndex, _ensure_index
/Users/amitanshu/anaconda/lib/python3.5/site-packages/pandas/core/frame.py in <module>()
39 create_block_manager_from_arrays,
40 create_block_manager_from_blocks)
---> 41 from pandas.core.series import Series
42 from pandas.core.categorical import Categorical
43 import pandas.computation.expressions as expressions
/Users/amitanshu/anaconda/lib/python3.5/site-packages/pandas/core/series.py in <module>()
2907 # Add plotting methods to Series
2908
-> 2909 import pandas.tools.plotting as _gfx
2910
2911 Series.plot = base.AccessorProperty(_gfx.SeriesPlotMethods, _gfx.SeriesPlotMethods)
/Users/amitanshu/anaconda/lib/python3.5/site-packages/pandas/tools/plotting.py in <module>()
26 from pandas.util.decorators import Appender
27 try: # mpl optional
---> 28 import pandas.tseries.converter as conv
29 conv.register() # needs to override so set_xlim works with str/number
30 except ImportError:
/Users/amitanshu/anaconda/lib/python3.5/site-packages/pandas/tseries/converter.py in <module>()
5 from dateutil.relativedelta import relativedelta
6
----> 7 import matplotlib.units as units
8 import matplotlib.dates as dates
9
/Users/amitanshu/anaconda/lib/python3.5/site-packages/matplotlib/__init__.py in <module>()
1129
1130 # this is the instance used by the matplotlib classes
-> 1131 rcParams = rc_params()
1132
1133 if rcParams['examples.directory']:
/Users/amitanshu/anaconda/lib/python3.5/site-packages/matplotlib/__init__.py in rc_params(fail_on_error)
973 return ret
974
--> 975 return rc_params_from_file(fname, fail_on_error)
976
977
/Users/amitanshu/anaconda/lib/python3.5/site-packages/matplotlib/__init__.py in rc_params_from_file(fname, fail_on_error, use_default_template)
1098 parameters specified in the file. (Useful for updating dicts.)
1099 """
-> 1100 config_from_file = _rc_params_in_file(fname, fail_on_error)
1101
1102 if not use_default_template:
/Users/amitanshu/anaconda/lib/python3.5/site-packages/matplotlib/__init__.py in _rc_params_in_file(fname, fail_on_error)
1016 cnt = 0
1017 rc_temp = {}
-> 1018 with _open_file_or_url(fname) as fd:
1019 try:
1020 for line in fd:
/Users/amitanshu/anaconda/lib/python3.5/contextlib.py in __enter__(self)
57 def __enter__(self):
58 try:
---> 59 return next(self.gen)
60 except StopIteration:
61 raise RuntimeError("generator didn't yield") from None
/Users/amitanshu/anaconda/lib/python3.5/site-packages/matplotlib/__init__.py in _open_file_or_url(fname)
998 else:
999 fname = os.path.expanduser(fname)
-> 1000 encoding = locale.getdefaultlocale()[1]
1001 if encoding is None:
1002 encoding = "utf-8"
/Users/amitanshu/anaconda/lib/python3.5/locale.py in getdefaultlocale(envvars)
557 else:
558 localename = 'C'
--> 559 return _parse_localename(localename)
560
561
/Users/amitanshu/anaconda/lib/python3.5/locale.py in _parse_localename(localename)
485 elif code == 'C':
486 return None, None
--> 487 raise ValueError('unknown locale: %s' % localename)
488
489 def _build_localename(localetuple):
ValueError: unknown locale: UTF-8
Try adding the following parameters to your ~/.bash_profile (by typing the below into terminal):
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
I'm trying to learn pandas by watching this video: https://www.youtube.com/watch?v=5JnMutdy6Fw. I downloaded the notebooks (https://github.com/brandon-rhodes/pycon-pandas-tutorial/), and loaded up Exercises-1. The first block
%matplotlib inline
import pandas as pd
is giving me this error:
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-10-5761ac74df30> in <module>()
----> 1 get_ipython().magic(u'matplotlib inline')
2 import pandas as pd
/Users/***/anaconda/lib/python2.7/site-packages/IPython/core/interactiveshell.pyc in magic(self, arg_s)
2305 magic_name, _, magic_arg_s = arg_s.partition(' ')
2306 magic_name = magic_name.lstrip(prefilter.ESC_MAGIC)
-> 2307 return self.run_line_magic(magic_name, magic_arg_s)
2308
2309 #-------------------------------------------------------------------------
/Users/***/anaconda/lib/python2.7/site-packages/IPython/core/interactiveshell.pyc in run_line_magic(self, magic_name, line)
2226 kwargs['local_ns'] = sys._getframe(stack_depth).f_locals
2227 with self.builtin_trap:
-> 2228 result = fn(*args,**kwargs)
2229 return result
2230
/Users/***/anaconda/lib/python2.7/site-packages/IPython/core/magics/pylab.pyc in matplotlib(self, line)
/Users/***/anaconda/lib/python2.7/site-packages/IPython/core/magic.pyc in <lambda>(f, *a, **k)
191 # but it's overkill for just that one bit of state.
192 def magic_deco(arg):
--> 193 call = lambda f, *a, **k: f(*a, **k)
194
195 if callable(arg):
/Users/***/anaconda/lib/python2.7/site-packages/IPython/core/magics/pylab.pyc in matplotlib(self, line)
86 """
87 args = magic_arguments.parse_argstring(self.matplotlib, line)
---> 88 gui, backend = self.shell.enable_matplotlib(args.gui)
89 self._show_matplotlib_backend(args.gui, backend)
90
/Users/***/anaconda/lib/python2.7/site-packages/IPython/core/interactiveshell.pyc in enable_matplotlib(self, gui)
3087 """
3088 from IPython.core import pylabtools as pt
-> 3089 gui, backend = pt.find_gui_and_backend(gui, self.pylab_gui_select)
3090
3091 if gui != 'inline':
/Users/***/anaconda/lib/python2.7/site-packages/IPython/core/pylabtools.pyc in find_gui_and_backend(gui, gui_select)
237 """
238
--> 239 import matplotlib
240
241 if gui and gui != 'auto':
/Users/***/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/matplotlib/__init__.py in <module>()
178 # cbook must import matplotlib only within function
179 # definitions, so it is safe to import from it here.
--> 180 from matplotlib.cbook import is_string_like
181 from matplotlib.compat import subprocess
182
/Users/***/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/matplotlib/cbook.py in <module>()
31 from weakref import ref, WeakKeyDictionary
32
---> 33 import numpy as np
34 import numpy.ma as ma
35
/Users/***/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/numpy/__init__.py in <module>()
183 return loader(*packages, **options)
184
--> 185 from . import add_newdocs
186 __all__ = ['add_newdocs',
187 'ModuleDeprecationWarning',
/Users/***/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/numpy/add_newdocs.py in <module>()
11 from __future__ import division, absolute_import, print_function
12
---> 13 from numpy.lib import add_newdoc
14
15 ###############################################################################
/Users/***/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/numpy/lib/__init__.py in <module>()
15 from .ufunclike import *
16
---> 17 from . import scimath as emath
18 from .polynomial import *
19 #import convertcode
ImportError: cannot import name scimath
Can someone tell me what's happening and how I can fix it?
You can read about a similar issue here and here.
The main problem is with importing scimath:
"ImportError: cannot import name scimath"
You can try to import scimath.
A better solution would be to set your PYTHONPATH var, which provides the python interpreter with additional directories look in for python packages/modules. You can read more about setting PYTHONPATH variable here.
After some fixing my PATH variable to get some library installs to work , I'm finding that my IPython Notebook (Enthought Canopy on Ubuntu 14.04) throws the following error when using the %matplotlib magic command:
ImportError: /home/joe/Enthought/Canopy_64bit/User/bin/../lib/libgfortran.so.3: version `GFORTRAN_1.4' not found (required by /usr/lib/liblapack.so.3)
I'm also getting this error when trying to install python-bio-formats, pims, and pylibtiff.
Again, any ideas are appreciated.
EDIT: Full error traceback:
ImportError Traceback (most recent call last)
<ipython-input-1-3042faeb62d7> in <module>()
----> 1 get_ipython().magic(u'matplotlib')
2 #import cv2
3 #import numpy as np
4 #import pandas as pd
5 #import os
/home/joe/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/IPython/core/interactiveshell.pyc in magic(self, arg_s)
2203 magic_name, _, magic_arg_s = arg_s.partition(' ')
2204 magic_name = magic_name.lstrip(prefilter.ESC_MAGIC)
-> 2205 return self.run_line_magic(magic_name, magic_arg_s)
2206
2207 #-------------------------------------------------------------------------
/home/joe/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/IPython/core/interactiveshell.pyc in run_line_magic(self, magic_name, line)
2124 kwargs['local_ns'] = sys._getframe(stack_depth).f_locals
2125 with self.builtin_trap:
-> 2126 result = fn(*args,**kwargs)
2127 return result
2128
/home/joe/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/IPython/core/magics/pylab.pyc in matplotlib(self, line)
/home/joe/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/IPython/core/magic.pyc in <lambda>(f, *a, **k)
191 # but it's overkill for just that one bit of state.
192 def magic_deco(arg):
--> 193 call = lambda f, *a, **k: f(*a, **k)
194
195 if callable(arg):
/home/joe/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/IPython/core/magics/pylab.pyc in matplotlib(self, line)
78 """
79 args = magic_arguments.parse_argstring(self.matplotlib, line)
---> 80 gui, backend = self.shell.enable_matplotlib(args.gui)
81 self._show_matplotlib_backend(args.gui, backend)
82
/home/joe/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/IPython/core/interactiveshell.pyc in enable_matplotlib(self, gui)
2929 """
2930 from IPython.core import pylabtools as pt
-> 2931 gui, backend = pt.find_gui_and_backend(gui, self.pylab_gui_select)
2932
2933 if gui != 'inline':
/home/joe/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/IPython/core/pylabtools.pyc in find_gui_and_backend(gui, gui_select)
250 """
251
--> 252 import matplotlib
253
254 if gui and gui != 'auto':
/home/joe/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/matplotlib/__init__.py in <module>()
177 # cbook must import matplotlib only within function
178 # definitions, so it is safe to import from it here.
--> 179 from matplotlib.cbook import is_string_like
180 from matplotlib.compat import subprocess
181
/home/joe/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/matplotlib/cbook.py in <module>()
30 from weakref import ref, WeakKeyDictionary
31
---> 32 import numpy as np
33 import numpy.ma as ma
34
/home/joe/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/numpy/__init__.pyc in <module>()
168 return loader(*packages, **options)
169
--> 170 from . import add_newdocs
171 __all__ = ['add_newdocs',
172 'ModuleDeprecationWarning',
/home/joe/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/numpy/add_newdocs.py in <module>()
11 from __future__ import division, absolute_import, print_function
12
---> 13 from numpy.lib import add_newdoc
14
15 ###############################################################################
/home/joe/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/numpy/lib/__init__.py in <module>()
16
17 from . import scimath as emath
---> 18 from .polynomial import *
19 #import convertcode
20 from .utils import *
/home/joe/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/numpy/lib/polynomial.py in <module>()
17 from numpy.lib.function_base import trim_zeros, sort_complex
18 from numpy.lib.type_check import iscomplex, real, imag
---> 19 from numpy.linalg import eigvals, lstsq, inv
20
21 class RankWarning(UserWarning):
/home/joe/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/numpy/linalg/__init__.py in <module>()
49 from .info import __doc__
50
---> 51 from .linalg import *
52
53 from numpy.testing import Tester
/home/joe/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/numpy/linalg/linalg.py in <module>()
27 )
28 from numpy.lib import triu, asfarray
---> 29 from numpy.linalg import lapack_lite, _umath_linalg
30 from numpy.matrixlib.defmatrix import matrix_power
31 from numpy.compat import asbytes
ImportError: /home/joe/Enthought/Canopy_64bit/User/bin/../lib/libgfortran.so.3: version `GFORTRAN_1.4' not found (required by /usr/lib/liblapack.so.3)
Full PATH (from echo $PATH):
/home/joe/Enthought/Canopy_64bit/User/bin:
/home/joe/Enthought/Canopy_64bit/User/bin:
/usr/local/sbin:
/usr/local/bin:
/usr/sbin:
/usr/bin:
/sbin:
/bin:
/usr/games:
/usr/local/games
sys.path:
['', '/home/joe/Enthought/Canopy_64bit/User/src/svn',
'/home/joe/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/pims',
'/home/joe/Canopy/appdata/canopy-1.4.1.1975.rh5-x86_64/lib/python27.zip',
'/home/joe/Canopy/appdata/canopy-1.4.1.1975.rh5-x86_64/lib/python2.7',
'/home/joe/Canopy/appdata/canopy-1.4.1.1975.rh5-x86_64/lib/python2.7/plat-linux2',
'/home/joe/Canopy/appdata/canopy-1.4.1.1975.rh5-x86_64/lib/python2.7/lib-tk',
'/home/joe/Canopy/appdata/canopy-1.4.1.1975.rh5-x86_64/lib/python2.7/lib-old',
'/home/joe/Canopy/appdata/canopy-1.4.1.1975.rh5-x86_64/lib/python2.7/lib-dynload',
'/home/joe/Enthought/Canopy_64bit/User/lib/python2.7/site-packages',
'/home/joe/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/PIL',
'/home/joe/opencv-2.4.9',
'/home/joe/Canopy/appdata/canopy-1.4.1.1975.rh5-x86_64/lib/python2.7/site-packages']
I was able to resolve this error by following the steps outlined here (specifically, steps 3-5): https://support.enthought.com/entries/23580651-Uninstalling-and-resetting-Canopy.
When re-attempting to install pims (https://github.com/soft-matter/pims) using pip (command: pip install --upgrade http://github.com/soft-matter/pims/zipball/master), the problem is able to be replicated. Odd.
I'm also getting a problem when trying to install pylibtiff via its setup.py script, but I will post this in another SO post, further detailing the error.
This might be late, but you can try the following thread
https://github.com/ContinuumIO/anaconda-issues/issues/686
Specifically the one by Zarhid:
conda remove libgfortran
conda install libgcc --force
replace conda with pip and modify accordingly. Worked for me