donkirkby / live-py-plugin

Live coding in Python with PyCharm, Emacs, Sublime Text, or even a browser
https://donkirkby.github.io/live-py-plugin
MIT License
289 stars 57 forks source link

"zsh:1: command not found: python" error #609

Closed notUserX closed 2 months ago

notUserX commented 2 months ago

What I did

Launched Emacs. Opened .py file. M-x live-py-mode

What happened

(zsh:1: command not found: python)

What I wanted to happen

I wanted to visualize my code instantly.

My environment

Other feedback

I was searching for REPL options in Emacs and stumbled upon your project.

donkirkby commented 2 months ago

The error message says that you don't have a python command in your path, so you have two options:

  1. Set the Python version with C-c M-v. You probably want to use python3 or python3.10. Try C-h m and scroll down to the live-py mode section to see all the options you can configure.
  2. Activate a Python virtual environment before you launch Emacs. That will put a python command in your path.

If that doesn't work, you can reopen this issue and add the details of what's going wrong.

notUserX commented 2 months ago

Thanks for your reply.

C-c M-v <ret> python3 <ret> solves my problem.

After this, C-h v shows that my live-py-version is set to "/opt/homebrew/bin/python3"

However, with the following in my .init file

`(defun my-live-py-mode-hook () "Hook function to set live-py-version." (setq live-py-version "/opt/homebrew/bin/python3"))

(add-hook 'live-py-mode-hook 'my-live-py-mode-hook)`

C-h v also shows that my live-py-version is set to "/opt/homebrew/bin/python3", yet M-x live-py-mode generates the (zsh:1: command not found: python) error.

I would have thought that it would not matter how live-py-version is set, but apparently, it does.

Aha!

Reviewing live-py-mode.el, I see that defun live-py-set-version() calls (live-py-update-all) after the setq. Adding this to my hook solves my problem; i.e., live-py is now finding python without further intervention.