luk400 / vim-jukit

Jupyter-Notebook inspired Neovim/Vim Plugin
MIT License
582 stars 23 forks source link

ValueError: invalid literal for int() with base 10: '' #2

Closed dostoievsky closed 2 years ago

dostoievsky commented 2 years ago

I am getting the following error when I try to render a graph with vim-jukit, can you help me solve this?

## -- End pasted text --
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Input In [7], in <cell line: 160>()
    156 smart_house = Agente(ambiente_atuacao)
    157 smart_house.executa_agente(20)
--> 160 Imprime.imprime_resultado(smart_house)

Input In [7], in Imprime.imprime_resultado(agente)
    129 plt.plot(historico_dias, agente.ambiente.historico_preco, 'bo--', label='Historico (preço)')
    130 plt.legend()
--> 131 plt.show()
    133 # Segunda impressão: historico qtde itens comprados
    134 fig, ax = plt.subplots()

File ~/.asdf/installs/python/3.10.4/lib/python3.10/site-packages/matplotlib/pyplot.py:368, in show(*args, **kwargs)
    324 """
    325 Display all open figures.
    326 
   (...)
    365 explicitly there.
    366 """
    367 _warn_if_gui_out_of_main_thread()
--> 368 return _backend_mod.show(*args, **kwargs)

File ~/.vim/plugged/vim-jukit/helpers/matplotlib-backend-kitty/__init__.py:66, in _BackendICatAgg.show(*args, **kwargs)
     65 def show(*args, **kwargs):
---> 66     _Backend.show(*args, **kwargs)
     67     Gcf.destroy_all()

File ~/.asdf/installs/python/3.10.4/lib/python3.10/site-packages/matplotlib/backend_bases.py:3524, in _Backend.show(cls, block)
   3522 for manager in managers:
   3523     try:
-> 3524         manager.show()  # Emits a warning for non-interactive backend.
   3525     except NonGuiException as exc:
   3526         _api.warn_external(str(exc))

File ~/.vim/plugged/vim-jukit/helpers/matplotlib-backend-kitty/__init__.py:38, in FigureManagerICat.show(self)
     36 # gather terminal dimensions
     37 px = icat('--print-window-size')
---> 38 px = list(map(int, px.split('x')))
     40 # resize figure to terminal size & aspect ratio
     41 dpi = self.canvas.figure.dpi

ValueError: invalid literal for int() with base 10: ''

also, my %paste is not working! Idk if I configured wrong, but I get in line one and go to the last with shift+v and then press Y, when I hit enter it dosent work. How it realy work? I should press the bind key, select, then crtl+c, then enter?

but that shit is realy cool and will help me alot, thank you!!!!

luk400 commented 2 years ago

Hi!

Please specify the kitty version you're using (kitty --version in your terminal). In your terminal, what is the output of kitty +kitten icat --print-window-size?

For the mappings used to send code to the terminal please refer to the readme, by default simply press enter to send the current line, press enter while in visual mode to send the current visual selection, leader+space to send code within current section (i.e. between cell markers), etc.. If you already have other mappings for those keys or want to set different ones, you can do so in your vim config.

dostoievsky commented 2 years ago
kitty 0.24.4 created by Kovid Goyal
 > kitty +kitten icat --print-window-size                                                             
Traceback (most recent call last):
  File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/usr/bin/../lib/kitty/__main__.py", line 185, in <module>
    main()
  File "/usr/bin/../lib/kitty/__main__.py", line 176, in main
    namespaced(['+', first_arg[1:]] + sys.argv[2:])
  File "/usr/bin/../lib/kitty/__main__.py", line 129, in namespaced
    func(args[1:])
  File "/usr/bin/../lib/kitty/__main__.py", line 112, in run_kitten
    rk(kitten)
  File "/usr/bin/../lib/kitty/kittens/runner.py", line 120, in run_kitten
    runpy.run_module(f'kittens.{kitten}.main', run_name=run_name)
  File "/usr/lib/python3.10/runpy.py", line 212, in run_module
    return _run_code(code, {}, init_globals, run_name, mod_spec)
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/usr/bin/../lib/kitty/kittens/icat/main.py", line 613, in <module>
    main()
  File "/usr/bin/../lib/kitty/kittens/icat/main.py", line 518, in main
    ss = screen_size_function(tty)()
  File "/usr/bin/../lib/kitty/kitty/utils.py", line 176, in __call__
    self.ans = read_screen_size(self.fd)
  File "/usr/bin/../lib/kitty/kitty/utils.py", line 156, in read_screen_size
    if fd < 0:
TypeError: '<' not supported between instances of '_io.TextIOWrapper' and 'int'

I instaled kitty as an pacman package with -Syu.

luk400 commented 2 years ago

This is an issue with kitty. Testing with version 0.24.4 I'm getting the same error. You might want to create an issue on the kitty repo for this. To get this plugin working, simply install an older version of kitty (e.g. 0.24.2) and it should work.

dostoievsky commented 2 years ago

Thank you! I'll refer that issue on kitty repo. As you help me I am closing that issue.

dostoievsky commented 2 years ago

2022-04-02-215550_1920x1080_scrot

Hey it worked!!!

I instaled kitty just for this, usualy I use alacritty with tmux, but, I read on kitty page that uses tmux with kitty is bad, how you've been doing to switch betwen panes?

I looked on web for how doing that but I didnt find nothing about how to configure kitty.

Can you tell me more about your setup? @luk400

Okay I just found something on web about:

https://sw.kovidgoyal.net/kitty/overview/

I'll leave here if newbs like me come around lol

luk400 commented 2 years ago

Glad to hear it's working! You should find most of what you'll need here. But for reference, my config file ~/.config/kitty/kitty.conf currently has, among some other highly specifc mappings for my workflow, the following (probably not super well thought out) mappings:

# use <alt> key as kitty_mod
kitty_mod alt

# close/create windows/tabs
map kitty_mod+enter new_window_with_cwd
map kitty_mod+q close_window
map kitty_mod+t new_tab_with_cwd

# move to next tab
map kitty_mod+space next_tab

# move between windows
map ctrl+j neighboring_window down
map ctrl+k neighboring_window up
map ctrl+h neighboring_window left
map ctrl+l neighboring_window right

# font size
map ctrl+plus change_font_size current +2.0
map ctrl+minus change_font_size current -2.0

# Clear the terminal screen by erasing all contents
map kitty_mod+backspace combine : clear_terminal clear active : send_text

# window resizing
map kitty_mod+< resize_window wider 3
map kitty_mod+shift+< resize_window narrower 3
map kitty_mod+plus resize_window taller 3
map kitty_mod+minus resize_window shorter 3

window_resize_step_cells 2
window_resize_step_lines 2

# moving windows around
map kitty_mod+k move_window up
map kitty_mod+h move_window left
map kitty_mod+l move_window right
map kitty_mod+j move_window down

# switch between layouts
map ctrl+, next_layout

# clipboard
map ctrl+shift+c copy_to_clipboard
map ctrl+shift+v paste_from_clipboard

# scrolling
map ctrl+shift+k scroll_page_up
map ctrl+shift+j scroll_page_down
map ctrl+shift+space scroll_end

I also have a file ~/.config/kitty/theme.conf which I load at the end of kitty.conf with include ./theme.conf, which contains the following:

background #1A1F36
foreground #ffffff
cursor #f0cb09
selection_background #18344f
color0 #000000
color8 #38fbdc
color1 #ff0000
color9 #92e117
color2 #37dd21
color10 #3bcf1d
color3 #fee409
color11 #ecc809
color4 #1460d2
color12 #5555ff
color5 #ff005d
color13 #ff55ff
color6 #00bbbb
color14 #6ae3f9
color7 #bbbbbb
color15 #ffffff
selection_foreground #122637
font_size 12
font_family JetBrains Mono Regular
background_opacity 0.9
cursor #ffffff