The current analytical workspace code seems to have some import error.
I tried this ..
from cubes import Workspace
workspace = Workspace(config="slicer.ini")
workspace.import_model("model.json")
workspace.list_cubes()
And I get this error:
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-6-f80f0974af47> in <module>()
----> 1 workspace.list_cubes()
/home/anand/.virtualenvs/cubes/local/lib/python2.7/site-packages/cubes/workspace.pyc in list_cubes(self, identity)
535 """
536
--> 537 all_cubes = self.namespace.list_cubes(recursive=True)
538
539 if self.authorizer:
/home/anand/.virtualenvs/cubes/local/lib/python2.7/site-packages/cubes/namespace.pyc in list_cubes(self, recursive)
112 name = cube["name"]
113 if name in cube_names:
--> 114 raise ModelError("Duplicate cube '%s'" % name)
115 cube_names.add(name)
116
NameError: global name 'ModelError' is not defined
I'm using the 1.0.1 version.
And have tried the latest master from github, but that fails even at the
from cubes import Workspace
Related
Hi I have difficulties in fitting data using Fitter module in Python and I don't understand the error as I am quite new to Python. The following code below is what I done so far in order to get the summary.
import fitter
f=fitter.Fitter(data=data["ROAS"], distributions= ['gamma'])
f.fit()
f.summary()
The error I get is:
DistributionNotFound Traceback (most recent call last)
<ipython-input-29-c00604ced33b> in <module>
1 f=fitter.Fitter(data=data["ROAS"])
----> 2 f.fit()
3 f.summary()
~\anaconda3\lib\site-packages\fitter\fitter.py in fit(self, amp, progress)
259 warnings.filterwarnings("ignore", category=RuntimeWarning)
260
--> 261 from easydev import Progress
262 N = len(self.distributions)
263 pb = Progress(N)
~\anaconda3\lib\site-packages\easydev\__init__.py in <module>
28 version = __version__
29 else:
---> 30 version = pkg_resources.require("easydev")[0].version
31 __version__ = version
32
~\anaconda3\lib\site-packages\pkg_resources\__init__.py in require(self, *requirements)
882 included, even if they were already activated in this working set.
883 """
--> 884 needed = self.resolve(parse_requirements(requirements))
885
886 for dist in needed:
~\anaconda3\lib\site-packages\pkg_resources\__init__.py in resolve(self, requirements, env, installer, replace_conflicting, extras)
768 if dist is None:
769 requirers = required_by.get(req, None)
--> 770 raise DistributionNotFound(req, requirers)
771 to_activate.append(dist)
772 if dist not in req:
DistributionNotFound: The 'ptyprocess>=0.5' distribution was not found and is required by pexpect
Please can someone help me to run the code without the error, thanks.
I had the same problem. I installed the "ptyprocess" library and now it works.
I am using ipwhois for the first time. Running the basic usage example with a Google IP address works:
from ipwhois import IPWhois
obj = IPWhois('74.125.225.229')
results = obj.lookup_rdap(depth=1)
Any other IP address results in this error:
ASNRegistryError Traceback (most recent call last)
<ipython-input-62-03afc25be9cd> in <module>()
----> 1 results = obj.lookup_rdap(depth=1)
~\_installed\anaconda\envs\geocode\lib\site-packages\ipwhois\ipwhois.py in lookup_rdap(self, inc_raw, retry_count, depth, excluded_entities, bootstrap, rate_limit_timeout, asn_alts, extra_org_map, inc_nir, nir_field_list, asn_methods, get_asn_description)
306 inc_raw=inc_raw, retry_count=retry_count, asn_alts=asn_alts,
307 extra_org_map=extra_org_map, asn_methods=asn_methods,
--> 308 get_asn_description=get_asn_description
309 )
310
~\_installed\anaconda\envs\geocode\lib\site-packages\ipwhois\asn.py in lookup(self, inc_raw, retry_count, asn_alts, extra_org_map, asn_methods, get_asn_description)
569 if asn_data is None:
570
--> 571 raise ASNRegistryError('ASN lookup failed with no more methods to '
572 'try.')
573
ASNRegistryError: ASN lookup failed with no more methods to try.
I attempted to switch the lookup method to ARIN with bootstrap=True to no avail. How do I remedy this error?
I am trying to set up sacred for Python and I am going through the tutorial. I was able to set up sacred using pip install sacred with no issues. I am having trouble running the basic code:
from sacred import Experiment
ex = Experiment("hello_world")
Running this code returns the a ValueError:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-25-66f549cfb192> in <module>()
1 from sacred import Experiment
2
----> 3 ex = Experiment("hello_world")
/Users/ryandevera/anaconda/lib/python2.7/site-packages/sacred/experiment.pyc in __init__(self, name, ingredients)
42 super(Experiment, self).__init__(path=name,
43 ingredients=ingredients,
---> 44 _caller_globals=caller_globals)
45 self.default_command = ""
46 self.command(print_config, unobserved=True)
/Users/ryandevera/anaconda/lib/python2.7/site-packages/sacred/ingredient.pyc in __init__(self, path, ingredients, _caller_globals)
48 self.doc = _caller_globals.get('__doc__', "")
49 self.sources, self.dependencies = \
---> 50 gather_sources_and_dependencies(_caller_globals)
51
52 # =========================== Decorators ==================================
/Users/ryandevera/anaconda/lib/python2.7/site-packages/sacred/dependencies.pyc in gather_sources_and_dependencies(globs)
204 def gather_sources_and_dependencies(globs):
205 dependencies = set()
--> 206 main = Source.create(globs.get('__file__'))
207 sources = {main}
208 experiment_path = os.path.dirname(main.filename)
/Users/ryandevera/anaconda/lib/python2.7/site-packages/sacred/dependencies.pyc in create(filename)
61 if not filename or not os.path.exists(filename):
62 raise ValueError('invalid filename or file not found "{}"'
---> 63 .format(filename))
64
65 mainfile = get_py_file_if_possible(os.path.abspath(filename))
ValueError: invalid filename or file not found "None"
I am not sure why this error is returning. The documentation does not say anything about setting up an Experiment file prior to running the code. Any help would be greatly appreciated!
The traceback given indicates that the constructor for Experiment searches its namespace to find the file in which its defined.
Thus, to make the example work, place the example code into a file and run that file directly.
If you are using ipython, then you could always try using the %%python command, which will effectively capture the code you give it into a file before running it (in a separate python process).
According to the docs, if you're in IPython/Jupyter, you can allow the Experiment to run in a non-reproducible interactive environment:
ex = Experiment('jupyter_ex', interactive=True)
https://sacred.readthedocs.io/en/latest/experiment.html#run-the-experiment
The docs say it nicely (TL;DR: sacred checks this for you and fails in order to warn you)
Warning
By default, Sacred experiments will fail if run in an interactive
environment like a REPL or a Jupyter Notebook. This is an intended
security measure since in these environments reproducibility cannot be
ensured. If needed, this safeguard can be deactivated by passing
interactive=True to the experiment like this:
ex = Experiment('jupyter_ex', interactive=True)
Setting interactive=True doesn't work if you run the notebook as a script through ipython.
$ ipython code.ipynb
---------------------------------------------------------------------------
AssertionError Traceback (most recent call last)
Cell In[1], line 1
----> 1 ex = Experiment("image_classification", interactive=True)
2 ex.observers.append(NeptuneObserver(run=neptune_run))
File ~\miniconda3\envs\py38\lib\site-packages\sacred\experiment.py:119, in Experiment.__init__(self, name, ingredients, interactive, base_dir, additional_host_info, additional_cli_options, save_git_info)
117 elif name.endswith(".pyc"):
118 name = name[:-4]
--> 119 super().__init__(
120 path=name,
121 ingredients=ingredients,
122 interactive=interactive,
123 base_dir=base_dir,
124 _caller_globals=caller_globals,
125 save_git_info=save_git_info,
126 )
127 self.default_command = None
128 self.command(print_config, unobserved=True)
File ~\miniconda3\envs\py38\lib\site-packages\sacred\ingredient.py:75, in Ingredient.__init__(self, path, ingredients, interactive, _caller_globals, base_dir, save_git_info)
69 self.save_git_info = save_git_info
70 self.doc = _caller_globals.get("__doc__", "")
71 (
72 self.mainfile,
73 self.sources,
74 self.dependencies,
---> 75 ) = gather_sources_and_dependencies(
76 _caller_globals, save_git_info, self.base_dir
77 )
78 if self.mainfile is None and not interactive:
79 raise RuntimeError(
80 "Defining an experiment in interactive mode! "
81 "The sourcecode cannot be stored and the "
82 "experiment won't be reproducible. If you still"
83 " want to run it pass interactive=True"
84 )
File ~\miniconda3\envs\py38\lib\site-packages\sacred\dependencies.py:725, in gather_sources_and_dependencies(globs, save_git_info, base_dir)
723 def gather_sources_and_dependencies(globs, save_git_info, base_dir=None):
724 """Scan the given globals for modules and return them as dependencies."""
--> 725 experiment_path, main = get_main_file(globs, save_git_info)
727 base_dir = base_dir or experiment_path
729 gather_sources = source_discovery_strategies[SETTINGS["DISCOVER_SOURCES"]]
File ~\miniconda3\envs\py38\lib\site-packages\sacred\dependencies.py:596, in get_main_file(globs, save_git_info)
594 main = None
595 else:
--> 596 main = Source.create(globs.get("__file__"), save_git_info)
461 return Source(main_file, get_digest(main_file), repo, commit, is_dirty)
File ~\miniconda3\envs\py38\lib\site-packages\sacred\dependencies.py:382, in get_py_file_if_possible(pyc_name)
380 if pyc_name.endswith((".py", ".so", ".pyd")):
381 return pyc_name
--> 382 assert pyc_name.endswith(".pyc")
383 non_compiled_file = pyc_name[:-1]
384 if os.path.exists(non_compiled_file):
sacred==0.8.2
Setup: Using Python 3.4.1 from the Anaconda 2.1.0 64-bit installer for Windows 8.1
Using IPython 2.2.0 console
As usual with the Anaconda installer, I have matplotlib 1.4.0 that comes with it.
And I updated from the default sympy on Anaconda to sympy 0.7.6
Problem: I am trying to plot geometric entities as discussed in the sympy documentation http://docs.sympy.org/latest/modules/plotting.html#plot-geom in at least three ways, all yielding errors.
First try using the 'older' PygletPlot, the module being used in the above reference documentation:
In [1]: from sympy.plotting.pygletplot import PygletPlot as Plot
In [2]: from sympy import Point, Circle
In [3]: c1 = Circle(Point(1, 0), 3)
In [4]: p = Plot(axes='label_axes=True')
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-6-34da7d3c112c> in <module>()
----> 1 p = Plot(axes='label_axes=True')
C:\Anaconda3\lib\site-packages\sympy\plotting\pygletplot\__init__.py in PygletPlot(*args, **kwargs)
137 """
138
--> 139 import plot
140 return plot.PygletPlot(*args, **kwargs)
141
ImportError: No module named 'plot'
In [5]: Plot(c1)
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-5-4edba1117b3a> in <module>()
----> 1 Plot(c1)
C:\Anaconda3\lib\site-packages\sympy\plotting\pygletplot\__init__.py in PygletPlot(*args, **kwargs)
137 """
138
--> 139 import plot
140 return plot.PygletPlot(*args, **kwargs)
141
ImportError: No module named 'plot'
In [6]: p = Plot()
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-6-f2ff2ed54331> in <module>()
----> 1 p = Plot()
C:\Anaconda3\lib\site-packages\sympy\plotting\pygletplot\__init__.py in PygletPlot(*args, **kwargs)
137 """
138
--> 139 import plot
140 return plot.PygletPlot(*args, **kwargs)
141
ImportError: No module named 'plot'
Second try using the 'newer' plotting module, which keeps being recommended in answers for most plotting problems with sympy:
In [1]: from sympy.plotting.plot import Plot
In [2]: from sympy import Point, Circle
In [3]: c1 = Circle(Point(1, 0), 3)
In [4]: p = Plot(c1)
In [5]: p.show()
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-5-709f73884a30> in <module>()
----> 1 p.show()
C:\Anaconda3\lib\site-packages\sympy\plotting\plot.py in show(self)
182 if hasattr(self, '_backend'):
183 self._backend.close()
--> 184 self._backend = self.backend(self)
185 self._backend.show()
186
C:\Anaconda3\lib\site-packages\sympy\plotting\plot.py in __new__(cls, parent)
1054 matplotlib = import_module('matplotlib', min_module_version='1.1.0', catch=(RuntimeError,))
1055 if matplotlib:
-> 1056 return MatplotlibBackend(parent)
1057 else:
1058 return TextBackend(parent)
C:\Anaconda3\lib\site-packages\sympy\plotting\plot.py in __init__(self, parent)
861 def __init__(self, parent):
862 super(MatplotlibBackend, self).__init__(parent)
--> 863 are_3D = [s.is_3D for s in self.parent._series]
864 self.matplotlib = import_module('matplotlib',
865 __import__kwargs={'fromlist': ['pyplot', 'cm', 'collections']},
C:\Anaconda3\lib\site-packages\sympy\plotting\plot.py in <listcomp>(.0)
861 def __init__(self, parent):
862 super(MatplotlibBackend, self).__init__(parent)
--> 863 are_3D = [s.is_3D for s in self.parent._series]
864 self.matplotlib = import_module('matplotlib',
865 __import__kwargs={'fromlist': ['pyplot', 'cm', 'collections']},
AttributeError: 'Circle' object has no attribute 'is_3D'
In [6]: Plot(c1)
Out[6]: <sympy.plotting.plot.Plot at 0x6f74ac8>
Third try using the plot() function which the sympy documentation recommends for interactive work:
In [1]: from sympy import plot
In [2]: from sympy import Point, Circle
In [3]: c1 = Circle(Point(1, 0), 3)
In [4]: plot(c1)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-4-685b4d90c5ac> in <module>()
----> 1 plot(c1)
C:\Anaconda3\lib\site-packages\sympy\plotting\plot.py in plot(*args, **kwargs)
1274 series = []
1275 plot_expr = check_arguments(args, 1, 1)
-> 1276 series = [LineOver1DRangeSeries(*arg, **kwargs) for arg in plot_expr]
1277
1278 plots = Plot(*series, **kwargs)
TypeError: 'NoneType' object is not iterable
Thanks for your attention. This is my first time writing a question so I hope I have provided enough information.
I'm trying to reproduce the result of the example file provided by Prof. Zhao using Enthought Canopy:
http://www.shengdongzhao.com/shen_blog/how-to-automatically-create-powerpoint-slides-using-python/
I seem to be having the same problem that others are having (and seem to still be having) which you can see in the comments below the linked blog post. I realize prof. Zhao mentions that the error could be due to the environment not being set correctly. I thought it might have something to do with environment variables not being pointed to correctly. I tried the the first answer at the following but it seems like it prevents canopy from even opening (doing something wrong I am)
How to add to the pythonpath in windows 7?
So what I'm left doing is: I open his scripts in Canopy and then I run MSO.py and then MSPPT.py and then MSPPTUtil.py. Then, when I run CreateSlideExamples.py (with photo.JPG's directory updated) I only get a single power-point slide with the table
The console is littered with the following list of errors:
%run C:/Users/dirkh_000/AppData/Local/Temp/Temp1_MSPPT.zip/MSO.py
%run "C:/Users/dirkh_000/Documents/Python scripts/Auto pp example/MSPPT.py"
%run "C:/Users/dirkh_000/Documents/Python scripts/Auto pp example/MSPPTUtil.py"
%run "C:/Users/dirkh_000/Documents/Python scripts/Auto pp example/CreateSlideExamples.py"
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
C:\Users\dirkh_000\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.4.1.1975.win-x86_64\lib\site-packages\IPython\utils\py3compat.pyc in execfile(fname, glob, loc)
195 else:
196 filename = fname
--> 197 exec compile(scripttext, filename, 'exec') in glob, loc
198 else:
199 def execfile(fname, *where):
C:\Users\dirkh_000\Documents\Python scripts\Auto pp example\CreateSlideExamples.py in <module>()
40
41 # step 3: show the slide
---> 42 presentation.create_show()
43
44 # Now you can save the slide somewhere
C:\Users\dirkh_000\Documents\Python scripts\Auto pp example\MSPPTUtil.pyc in create_show(self, visible)
45 if visible:
46 slide.select() #bring slide to front
---> 47 slide.format_slide()
48 def save_as(self, file_name):
49 self.presentation.SaveAs(file_name)
C:\Users\dirkh_000\Documents\Python scripts\Auto pp example\MSPPTUtil.pyc in format_slide(self)
64 self.slide.Select()
65 def format_slide(self):
---> 66 self.format_content()
67 self.format_title()
68 def format_title(self):
C:\Users\dirkh_000\Documents\Python scripts\Auto pp example\MSPPTUtil.pyc in format_content(self)
252 if self.title:
253 #add title
--> 254 title_range = slide.Shapes[0].TextFrame.TextRange
255 title_range.Text = self.title
256 title_range.Font.Bold = True
C:\Users\dirkh_000\AppData\Local\Enthought\Canopy\User\lib\site-packages\win32com\client\__init__.pyc in __getattr__(self, attr)
463 args=self._prop_map_get_.get(attr)
464 if args is None:
--> 465 raise AttributeError("'%s' object has no attribute '%s'" % (repr(self), attr))
466 return self._ApplyTypes_(*args)
467
AttributeError: '<win32com.gen_py.Microsoft PowerPoint 15.0 Object Library.Shapes instance at 0x164276808>' object has no attribute '__getitem__'
Any help is appreciated. I'm running windows 8.1, powerpoint 2013.