I try to run a CNN model on tensorflow using cifar10 library. However, when I import cifar10 and run the maybe_download_and_extract() method, it gives the following error. I am running it on tensorflow (1.5.0) and Python 3.6.4 :: Anaconda, Inc.
---------------------------------------------------------------------------
UnrecognizedFlagError Traceback (most recent call last)
<ipython-input-37-02a754d7036a> in <module>()
----> 1 cifar10.maybe_download_and_extract()
D:\Google Drive\Akademik\Ozyegin\CS566\Project 2\cifar10.py in maybe_download_and_extract()
~\anaconda3\lib\site-packages\tensorflow\python\platform\flags.py in __getattr__(self, name)
82 # a flag.
83 if not wrapped.is_parsed():
---> 84 wrapped(_sys.argv)
85 return wrapped.__getattr__(name)
86
~\anaconda3\lib\site-packages\absl\flags\_flagvalues.py in __call__(self, argv, known_only)
628 suggestions = _helpers.get_flag_suggestions(name, list(self))
629 raise _exceptions.UnrecognizedFlagError(
--> 630 name, value, suggestions=suggestions)
631
632 self.mark_as_parsed()
UnrecognizedFlagError: Unknown command line flag 'f'
Add following line to your jupyter notebook:
tf.app.flags.DEFINE_string('f', '', 'kernel')
Related
While the installation went smooth, I keep facing this error when I try to import torchtext on my macbook air m1
---------------------------------------------------------------------------
OSError Traceback (most recent call last)
Input In [10], in <cell line: 1>()
----> 1 import torchtext
File ~/Library/Python/3.8/lib/python/site-packages/torchtext/__init__.py:6, in <module>
3 from torch.hub import _get_torch_home
5 # the following import has to happen first in order to load the torchtext C++ library
----> 6 from torchtext import _extension # noqa: F401
8 _TEXT_BUCKET = "https://download.pytorch.org/models/text/"
10 _CACHE_DIR = os.path.expanduser(os.path.join(_get_torch_home(), "text"))
File ~/Library/Python/3.8/lib/python/site-packages/torchtext/_extension.py:64, in <module>
59 # This import is for initializing the methods registered via PyBind11
60 # This has to happen after the base library is loaded
61 from torchtext import _torchtext # noqa
---> 64 _init_extension()
File ~/Library/Python/3.8/lib/python/site-packages/torchtext/_extension.py:58, in _init_extension()
55 if not _mod_utils.is_module_available("torchtext._torchtext"):
56 raise ImportError("torchtext C++ Extension is not found.")
---> 58 _load_lib("libtorchtext")
59 # This import is for initializing the methods registered via PyBind11
60 # This has to happen after the base library is loaded
61 from torchtext import _torchtext
File ~/Library/Python/3.8/lib/python/site-packages/torchtext/_extension.py:50, in _load_lib(lib)
48 if not path.exists():
49 return False
---> 50 torch.ops.load_library(path)
51 return True
File ~/Library/Python/3.8/lib/python/site-packages/torch/_ops.py:220, in _Ops.load_library(self, path)
215 path = torch._utils_internal.resolve_library_path(path)
216 with dl_open_guard():
217 # Import the shared library into the process, thus running its
218 # static (global) initialization code in order to register custom
219 # operators with the JIT.
--> 220 ctypes.CDLL(path)
221 self.loaded_libraries.add(path)
File /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/ctypes/__init__.py:365, in CDLL.__init__(self, name, mode, handle, use_errno, use_last_error, winmode)
362 self._FuncPtr = _FuncPtr
364 if handle is None:
--> 365 self._handle = _dlopen(self._name, mode)
366 else:
367 self._handle = handle
OSError: dlopen(/Users/pratik/Library/Python/3.8/lib/python/site-packages/torchtext/lib/libtorchtext.so, 0x0006): Symbol not found: __ZN3c1012OptionalType3getENS_4Type24SingletonOrSharedTypePtrIS1_EE
Referenced from: /Users/pratik/Library/Python/3.8/lib/python/site-packages/torchtext/lib/libtorchtext.so
Expected in: /Users/pratik/Library/Python/3.8/lib/python/site-packages/torch/lib/libtorch_cpu.dylib
I don't quite understand what I can do about this. I uninstalled and reinstalled it all to avoid an error I was having previously. But now, this comes up.
OSError Traceback (most recent call last)
<ipython-input-2-7dd3504c366f> in <module>
----> 1 import pandas as pd
~\AppData\Roaming\Python\Python38\site-packages\pandas\__init__.py in <module>
9 for dependency in hard_dependencies:
10 try:
---> 11 __import__(dependency)
12 except ImportError as e:
13 missing_dependencies.append(f"{dependency}: {e}")
~\AppData\Roaming\Python\Python38\site-packages\numpy\__init__.py in <module>
136
137 # Allow distributors to run custom init code
--> 138 from . import _distributor_init
139
140 from . import core
~\AppData\Roaming\Python\Python38\site-packages\numpy\_distributor_init.py in <module>
24 # NOTE: would it change behavior to load ALL
25 # DLLs at this path vs. the name restriction?
---> 26 WinDLL(os.path.abspath(filename))
27 DLL_filenames.append(filename)
28 if len(DLL_filenames) > 1:
~\Anaconda3\lib\ctypes\__init__.py in __init__(self, name, mode, handle, use_errno, use_last_error,
winmode)
379
380 if handle is None:
--> 381 self._handle = _dlopen(self._name, mode)
382 else:
383 self._handle = handle
OSError: [WinError 193] %1 is not a valid Win32 application
I tried to "import pandas as pd" and this is the output in the jupyter notebook. what does the traceback(most recent call last) mean? Also why are there arrows pointing at specific lines?
I have been unable to identify the issue with Pymc3's inability to correctly run Theano. I have also been unable to find a satisfactory answer anywhere else online. I am working in Mac OSX Mojave using Anaconda and Python 3.6. I am trying to run the code on a Jupyter Notebook from "Probabilistic Programming and Bayesian Methods for Hackers".
https://nbviewer.jupyter.org/github/CamDavidsonPilon/Probabilistic-Programming-and-Bayesian-Methods-for-Hackers/blob/master/Chapter1_Introduction/Ch1_Introduction_PyMC3.ipynb
Code breaks with the first attempt to utilize Pymc3:
import pymc3 as pm
import theano.tensor as tt
with pm.Model() as model:
alpha = 1.0/count_data.mean() # Recall count_data is the
# variable that holds our txt counts
lambda_1 = pm.Exponential("lambda_1", alpha)
lambda_2 = pm.Exponential("lambda_2", alpha)
tau = pm.DiscreteUniform("tau", lower=0, upper=n_count_data - 1)
Error code follows, below. Thanks in advance.
ImportError Traceback (most recent call last)
/anaconda3/lib/python3.6/site-packages/theano/gof/lazylinker_c.py in <module>
80 version,
---> 81 actual_version, force_compile, _need_reload))
82 except ImportError:
ImportError: Version check of the existing lazylinker compiled file. Looking for version 0.211, but found None. Extra debug information: force_compile=False, _need_reload=True
During handling of the above exception, another exception occurred:
ImportError Traceback (most recent call last)
/anaconda3/lib/python3.6/site-packages/theano/gof/lazylinker_c.py in <module>
104 version,
--> 105 actual_version, force_compile, _need_reload))
106 except ImportError:
ImportError: Version check of the existing lazylinker compiled file. Looking for version 0.211, but found None. Extra debug information: force_compile=False, _need_reload=True
During handling of the above exception, another exception occurred:
Exception Traceback (most recent call last)
/anaconda3/lib/python3.6/site-packages/theano/gof/vm.py in <module>
673 raise theano.gof.cmodule.MissingGXX('lazylinker will not be imported if theano.config.cxx is not set.')
--> 674 from . import lazylinker_c
675
/anaconda3/lib/python3.6/site-packages/theano/gof/lazylinker_c.py in <module>
139 cmodule.GCC_compiler.compile_str(dirname, code, location=loc,
--> 140 preargs=args)
141 # Save version into the __init__.py file.
/anaconda3/lib/python3.6/site-packages/theano/gof/cmodule.py in compile_str(module_name, src_code, location, include_dirs, lib_dirs, libs, preargs, py_module, hide_symbols)
2398 raise Exception('Compilation failed (return status=%s): %s' %
-> 2399 (status, compile_stderr.replace('\n', '. ')))
2400 elif config.cmodule.compilation_warning and compile_stderr:
Exception: Compilation failed (return status=1): In file included from /Users/kthln/.theano/compiledir_Darwin-18.7.0-x86_64-i386-64bit-i386-3.6.9-64/lazylinker_ext/mod.cpp:1:. In file included from /anaconda3/include/python3.6m/Python.h:25:. /anaconda3/bin/../include/c++/v1/stdio.h:108:15: fatal error: 'stdio.h' file not found. #include_next <stdio.h>. ^~~~~~~~~. 1 error generated..
During handling of the above exception, another exception occurred:
AttributeError Traceback (most recent call last)
<ipython-input-48-f2e1580aa39f> in <module>
1 import pymc3 as pm
----> 2 import theano.tensor as tt
3
4
5 with pm.Model() as model:
/anaconda3/lib/python3.6/site-packages/theano/__init__.py in <module>
108 object2, utils)
109
--> 110 from theano.compile import (
111 SymbolicInput, In,
112 SymbolicOutput, Out,
/anaconda3/lib/python3.6/site-packages/theano/compile/__init__.py in <module>
10 from theano.compile.function_module import *
11
---> 12 from theano.compile.mode import *
13
14 from theano.compile.io import *
/anaconda3/lib/python3.6/site-packages/theano/compile/mode.py in <module>
9 import theano
10 from theano import gof
---> 11 import theano.gof.vm
12 from theano import config
13 from six import string_types
/anaconda3/lib/python3.6/site-packages/theano/gof/vm.py in <module>
681 except ImportError:
682 pass
--> 683 except (OSError, theano.gof.cmodule.MissingGXX) as e:
684 # OSError happens when g++ is not installed. In that case, we
685 # already changed the default linker to something else then CVM.
AttributeError: module 'theano' has no attribute 'gof'
Disregard. I noticed with an update I was running Python 3.7. Set up a separate conda env with Python 3.6 and it works fine.
I am using Python with anaconda distribution for converting a satellite image to array for further processing.But while using .ReadAsArray() function the below error is occurring.I have tried to search about the error but no proper results are coming.I have installed everything using conda command.
from osgeo import gdal
ds = gdal.Open('/home/alay/Desktop/Studies/2010/ndvi01jun2010.tif')
band = ds.GetRasterBand(1)
img= band.ReadAsArray()
The error occuring after executing the above code
ImportError Traceback (most recent call last)
~/.local/lib/python3.6/site-packages/osgeo/gdal_array.py in
swig_import_helper()
17 try:
---> 18 fp, pathname, description = imp.find_module('_gdal_array', [dirname(__file__)])
19 except ImportError:
~/anaconda3/lib/python3.6/imp.py in find_module(name, path)
296 else:
--> 297 raise ImportError(_ERR_MSG.format(name), name=name)
298
ImportError: No module named '_gdal_array'
During handling of the above exception, another exception occurred:
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-4-eae4e7981f3a> in <module>()
----> 1 img= band.ReadAsArray()
~/.local/lib/python3.6/site-packages/osgeo/gdal.py in ReadAsArray(self, xoff, yoff, win_xsize, win_ysize, buf_xsize, buf_ysize, buf_type, buf_obj, resample_alg, callback, callback_data)
2603 parameters should generally not be specified if buf_obj is specified. The array is returned"""
2604
-> 2605 from . import gdalnumeric
2606
2607 return gdalnumeric.BandReadAsArray( self, xoff, yoff,
~/.local/lib/python3.6/site-packages/osgeo/gdalnumeric.py in <module>()
----> 1 from osgeo.gdal_array import *
2 from numpy import *
~/.local/lib/python3.6/site-packages/osgeo/gdal_array.py in <module>()
26 fp.close()
27 return _mod
---> 28 _gdal_array = swig_import_helper()
29 del swig_import_helper
30 else:
~/.local/lib/python3.6/site-packages/osgeo/gdal_array.py in swig_import_helper()
18 fp, pathname, description = imp.find_module('_gdal_array', [dirname(__file__)])
19 except ImportError:
---> 20 import _gdal_array
21 return _gdal_array
22 if fp is not None:
ModuleNotFoundError: No module named '_gdal_array'
I run the following code from convolutional neural network tutorials on jupyter notebook with python 3 kernel, and got the ModuleNotFoundError: No module named 'autoreload';
import numpy as np
import h5py
import matplotlib.pyplot as plt
%matplotlib inline
plt.rcParams['figure.figsize'] = (5.0, 4.0) # set default size of plots
plt.rcParams['image.interpolation'] = 'nearest'
plt.rcParams['image.cmap'] = 'gray'
%load_ext autoreload
%autoreload 2
np.random.seed(1)
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-1-3d0ea63c7843> in <module>()
8 plt.rcParams['image.cmap'] = 'gray'
9
---> 10 get_ipython().magic('load_ext autoreload # reload modules before executing user code')
11 get_ipython().magic('autoreload 2 # Reload all modules (except those excluded by %aimport)')
12
/opt/conda/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 #-------------------------------------------------------------------------
/opt/conda/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-62> in load_ext(self, module_str)
/opt/conda/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):
/opt/conda/lib/python3.6/site-packages/IPython/core/magics/extension.py in load_ext(self, module_str)
35 if not module_str:
36 raise UsageError('Missing module name.')
---> 37 res = self.shell.extension_manager.load_extension(module_str)
38
39 if res == 'already loaded':
/opt/conda/lib/python3.6/site-packages/IPython/core/extensions.py in load_extension(self, module_str)
81 if module_str not in sys.modules:
82 with prepended_to_syspath(self.ipython_extension_dir):
---> 83 __import__(module_str)
84 mod = sys.modules[module_str]
85 if self._call_load_ipython_extension(mod):
ModuleNotFoundError: No module named 'autoreload'
I just couldn't find any solution on this issue. How should I fix this error?
The module autoreload belongs to the library IPython, which is running in the background on Jupyter.
The same error occurred to me and it was due to a blank space, see:
.
So make sure that there are no spaces at the end of the command!
I hit this same error because I had a comment after the magic command:
bad:
%load_ext autoreload # this comment should be removed
good:
%load_ext autoreload