Giter Site home page Giter Site logo

ipython-magic's People

Contributors

cjdrake avatar jbn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

ipython-magic's Issues

'Dot' object has no attribute 'encode'

I'm trying to make one of your extensions work (completely new to IPython, first notebook, first code I'm writing in python)... It's going well, trying to plot strings, like one would expect, but I'm not sure how to make objects plottable... I'm getting this error:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-5-b880cdad6015> in <module>()
----> 1 get_ipython().magic('dotobj fig6')

/Users/h/.pyenv/versions/3.5.0/lib/python3.5/site-packages/IPython/core/interactiveshell.py in magic(self, arg_s)
   2334         magic_name, _, magic_arg_s = arg_s.partition(' ')
   2335         magic_name = magic_name.lstrip(prefilter.ESC_MAGIC)
-> 2336         return self.run_line_magic(magic_name, magic_arg_s)
   2337 
   2338     #-------------------------------------------------------------------------

/Users/h/.pyenv/versions/3.5.0/lib/python3.5/site-packages/IPython/core/interactiveshell.py in run_line_magic(self, magic_name, line)
   2255                 kwargs['local_ns'] = sys._getframe(stack_depth).f_locals
   2256             with self.builtin_trap:
-> 2257                 result = fn(*args,**kwargs)
   2258             return result
   2259 

/Users/h/.ipython/extensions/gvmagic.py in dotobj(self, line)

/Users/h/.pyenv/versions/3.5.0/lib/python3.5/site-packages/IPython/core/magic.py 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/h/.ipython/extensions/gvmagic.py in dotobj(self, line)
     52     @line_magic
     53     def dotobj(self, line):
---> 54         self._from_obj(line, 'dot')
     55 
     56     @line_magic

/Users/h/.ipython/extensions/gvmagic.py in _from_obj(self, line, layout_engine)
    162             error("expected to_dot method to be callable w/o args")
    163         else:
--> 164             data = run_graphviz(s, layout_engine)
    165             if data:
    166                 display_svg(data, raw=True)

/Users/h/.ipython/extensions/gvmagic.py in run_graphviz(s, layout_engine)
     29 
     30     dot = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE)
---> 31     stdoutdata, stderrdata = dot.communicate(s.encode('utf-8'))
     32     status = dot.wait()
     33     if status == 0:

AttributeError: 'Dot' object has no attribute 'encode'

For code on the instance fig6, like:

    def to_dot(self, Args=set()):
        if type(Args) is not set:
            Args = set(Args)

        try:
            graph = pydot.Dot()
        except NameError:
            print("Not able to import pydot. This functionality will not work.")
            return

        for arg in self._Ar:
            graph.add_node(pydot.Node(str(arg), shape='circle'))

        for attack in self._df:
            graph.add_edge(pydot.Edge(str(attack.attacker), str(attack.attacked)))

        for arg in Args:
            graph.get_node(str(arg)).pop().set_shape('doublecircle')

        return graph

With requirements.txt:

-e git+https://github.com/nlhepler/pydot.git@adf18a858a63b321b7e4ffd964a24d73add1bf4f#egg=pydot-master
pyparsing==2.0.6

Since I'm so new at this, I don't really know how to continue...?

PS, also getting. Is this normal?

/Users/h/.pyenv/versions/3.5.0/lib/python3.5/site-packages/IPython/core/magics/extension.py:47: UserWarning: %install_ext` is deprecated, please distribute your extension(s)as a python packages.
  "as a python packages.", UserWarning)

Doesn't work with Jupyter

My version 6.1.0, and when I try to %load_ext gvmagic, I get the error message 'ImportError: No module named 'IPython.utils.warn''

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.