Running Python with Gvim

  • open gVim.
  • then using the File menu and MenuItem Open to open the pi.py file, which has the following small script:

enter image description here

How to execute this code with gVim?


EDIT

If I use either :! python pi.py :! python pi.py , either :w !python - , I get the following:

enter image description here

+6
source share
4 answers

You do not need to save the file, you can run the current buffer as stdin for a command such as python by typing:

 :w !python - 

(The hyphen at the end is probably not needed, python will usually use stdin by default)

edit: seeing that you are new to vim, note that this will not save the file, it will just run it. You will probably want to know how to save the file.

+12
source

Something like that. Enter the following command into the vi command.

 :! python test.py 
+3
source

If you have python support compiled in vim, you can use :pyfile % to run the current file. (python 2.7)

If you have python 3 support, use :py3file % instead

pyfile help

+3
source

It seems your environment variable% path% does not contain your python installation path.

Follow these steps:

  • Right click on My Computer
  • Select Properties
  • Go to advanced settings
  • Go to Environment Variables
  • Select "PATH" and click "Edit."
  • Add the following to the end of the line: "; C: \ python27 \;" (without quotes)

Note: change directory to python directory (e.g. c: \ python30)

Save everything and then close vim and all CMD and try again.

+2
source

Source: https://habr.com/ru/post/944316/


All Articles