473,491 Members | 2,179 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Running Python interpreter in Emacs

Hi,

I'm interested in running a Python interpreter in Emacs. I have Python
extensions for Emacs, and my python menu lists "C-c !" as the command
to run the interpreter. Yet when I run it I get the message "Spawning
Child Process: invalid argument." What do I need to do/download to fix
this?

I read in a post in this group from a while back where someone had the
following lines in his .emacs file:

(setq interpreter-mode-alist
(cons '("python" . python-mode)
interpreter-mode-alist))

Does that have something to do with it? Do I have to set my load-path
to my python interpreter?

Thanks,

Rex

Jul 19 '05 #1
12 12247

Rex> I'm interested in running a Python interpreter in Emacs. I have
Rex> Python extensions for Emacs, and my python menu lists "C-c !" as
Rex> the command to run the interpreter. Yet when I run it I get the
Rex> message "Spawning Child Process: invalid argument." What do I need
Rex> to do/download to fix this?

Good question. Works fine for me on MacOSX 10.3 w/ XEmacs 21.4.15,
python-mode 4.75 and Python built from CVS. Can you give some details of
your environment?

Rex> I read in a post in this group from a while back where someone had
Rex> the following lines in his .emacs file:

Rex> (setq interpreter-mode-alist
Rex> (cons '("python" . python-mode)
Rex> interpreter-mode-alist))

Rex> Does that have something to do with it?

I doubt it. What's the value of interpreter-mode-alist? I have

'("python" . python-mode)

in my list by default (as a side-effect of running python-mode).

Rex> Do I have to set my load-path to my python interpreter?

No. That's how Emacs finds Emacs Lisp files to load. Make sure the
"python" command resides in a directory on your PATH.

Skip
Jul 19 '05 #2
Hi,

this is what I have:

(autoload 'python-mode "python-mode" "Python mode." t)

(setq auto-mode-alist (append '(("\\.\\(py\\)$" .
python-mode)) auto-mode-alist))

Plus, you can always spawn a shell then call your script (if the point is to
have access to the output).

Regards,

Philippe

Rex Eastbourne wrote:
Hi,

I'm interested in running a Python interpreter in Emacs. I have Python
extensions for Emacs, and my python menu lists "C-c !" as the command
to run the interpreter. Yet when I run it I get the message "Spawning
Child Process: invalid argument." What do I need to do/download to fix
this?

I read in a post in this group from a while back where someone had the
following lines in his .emacs file:

(setq interpreter-mode-alist
(cons '("python" . python-mode)
interpreter-mode-alist))

Does that have something to do with it? Do I have to set my load-path
to my python interpreter?

Thanks,

Rex


Jul 19 '05 #3
Hi Skip and Philippe. I added the path for Python to PATH, but I still
get the same message (when I try executing the current buffer, I get
the message: "The system cannot find the path specified."

Philippe, I have the above lines of code in my .emacs file.

As for my environment, I'm running Emacs 21.4 on Windows XP.

Thanks a lot!

Jul 19 '05 #4
Hi,

Since I'm a Linux user, I went through the following procedure:

I installed emacs 20.7.1 and Python 2.4
I installed python-mode 1.0A into site-lisp
I added c:\python24 to my path

I put this .emacs on c:\ (see further down - I'm sure you don't need half of
it)

And everyhing is working fine: python mode is recognized and Ctr-C-C opens a
*Python Output* buffer with the results from my script:

print 1 ==> 1

Hope that helps,

Regards,
Philippe

************************************************** ***************************
(custom-set-variables
;; custom-set-variables was added by Custom -- don't edit or cut/paste it!
;; Your init file should contain only one such instance.
'(auto-compression-mode t nil (jka-compr))
'(case-fold-search t)
'(current-language-environment "UTF-8")
'(default-input-method "rfc1345")
'(global-font-lock-mode t nil (font-lock))
'(nil nil t)
'(outline-minor-mode t)
'(pc-select-meta-moves-sexps t)
'(pc-select-selection-keys-only t)
'(pc-selection-mode t t)
'(save-place t nil (saveplace))
'(show-paren-mode t nil (paren))
'(text-mode-hook (quote (turn-on-auto-fill text-mode-hook-identify)))
'(transient-mark-mode t))

;(mouse-wheel-mode t)
(setq indent-tabs-mode nil)
;;(speedbar)

(custom-set-faces
;; custom-set-faces was added by Custom -- don't edit or cut/paste it!
;; Your init file should contain only one such instance.
)
;(setq any mode-customization variables you want here)
(autoload 'visual-basic-mode "visual-basic-mode" "Visual Basic mode." t)
(autoload 'python-mode "python-mode" "Python mode." t)

(setq auto-mode-alist (append '(("\\.\\(py\\)$" .
python-mode)) auto-mode-alist))

(setq auto-mode-alist (append '(("\\.\\(frm\\|bas\\|cls\\)$" .
visual-basic-mode)) auto-mode-alist))
************************************************** ***************************

Rex Eastbourne wrote:
Hi Skip and Philippe. I added the path for Python to PATH, but I still
get the same message (when I try executing the current buffer, I get
the message: "The system cannot find the path specified."

Philippe, I have the above lines of code in my .emacs file.

As for my environment, I'm running Emacs 21.4 on Windows XP.

Thanks a lot!


Jul 19 '05 #5
I have the following in my .emacs:

(add-to-list 'load-path "C:\Program Files\Python24")

Is that enough? I didn't see anything similar to that in your .emacs
file, so I'm wondering if I'm supposed to add the path to my PATH
elsewhere.

Thanks,

Rex

Jul 19 '05 #6
I do not think there is any need to tell emacs where Python is; besides
having python.exe in your Windows $PATH.

Regards,

Philippe


Rex Eastbourne wrote:
I have the following in my .emacs:

(add-to-list 'load-path "C:\Program Files\Python24")

Is that enough? I didn't see anything similar to that in your .emacs
file, so I'm wondering if I'm supposed to add the path to my PATH
elsewhere.

Thanks,

Rex


Jul 19 '05 #7
I went to My Computer | Properties | Advanced | Environment Variables
and added c:\program files\python24 to both the PYTHONPATH and Path
variables. Still no luck. I don't know whether the path I'm talking
about is the same as the $PATH you referred to, or whether I'm supposed
to put python.exe explicitly somewhere; could someone refer me to a
place where I can read about these things?

Thanks!

Rex

Jul 19 '05 #8
Hi,

I was refering to the Windows $PATH which you can modify in the same dialog.
To make sure it's done properly, open a console (cmd.exe) and type python

Regards,

Philippe
Rex Eastbourne wrote:
I went to My Computer | Properties | Advanced | Environment Variables
and added c:\program files\python24 to both the PYTHONPATH and Path
variables. Still no luck. I don't know whether the path I'm talking
about is the same as the $PATH you referred to, or whether I'm supposed
to put python.exe explicitly somewhere; could someone refer me to a
place where I can read about these things?

Thanks!

Rex


Jul 19 '05 #9
>>>>> "Rex Eastbourne" <re************@gmail.com> (RE) wrote:
RE> I went to My Computer | Properties | Advanced | Environment Variables
RE> and added c:\program files\python24 to both the PYTHONPATH and Path
RE> variables. Still no luck. I don't know whether the path I'm talking
RE> about is the same as the $PATH you referred to, or whether I'm supposed
RE> to put python.exe explicitly somewhere; could someone refer me to a
RE> place where I can read about these things?


Is c:\program files\python24 the directory where python.exe is?
You can try two things:
1. Use "c:\program files\python24" in the PATH environment variable, i.e.
with the quotes.
2. Set emacs' variable py-python-command to the location of the python
executable, e.g.
(setq py-python-command "c:\\program files\\python24\\python.exe")
or use customize to set that variable.
--
Piet van Oostrum <pi**@cs.uu.nl>
URL: http://www.cs.uu.nl/~piet [PGP E17999C4]
Private email: pi**@vanoostrum.org
Jul 19 '05 #10
Yes! Thank you so much! (For some reason, by the way, I had to copy
python.exe to my c:/ directory, since the computer could never find the
path in program files/python24. But when I did that, and used
setq-py-python-command, it worked. I now have python.exe in two
locations.)

Jul 19 '05 #11
Rex Eastbourne wrote:
Yes! Thank you so much! (For some reason, by the way, I had to copy
python.exe to my c:/ directory,
No, you did _not_ need to copy it there. You did _not_ need to copy it
anywhere. Didn't copying an executable to your root directory [on any
operating system] strike you as being one or more of
unusual/strange/weird/dopey?
since the computer could never find the
path in program files/python24.
Probably because you didn't have quotes around it (needed because of the
space) as advised by another poster.

But when I did that, and used setq-py-python-command, it worked. I now have python.exe in two
locations.)


The Windows Python installer will by default install Python 2.x in
C:\Python2x

One hopes that defaults are sensibly chosen by sensible people. This
appears to have been the case here.

How did you manage to get your Python installed in C:\Program
Files\Python24?
Jul 19 '05 #12
Yes, I knew that copying it to my root was a kludge. But between that
and not having it work, I chose the former. (As you might be able to
tell from my posts, I tried multiple things and was frustrated.) I
tried putting quotes around "c:\program files\python24". It still
didn't work.

I chose to install Python in Program Files. I didn't know it would
cause any problems; I just thought it was good to have all my programs
in the same place. I guess I was wrong.

Jul 19 '05 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
3384
by: Peter Wu | last post by:
I'm giving vim a try to program Python. The following are the steps I follow to code/test a python program. vi test.py :wq :!python test.py Is there any other way? I don't want to type...
147
7597
by: Sateesh | last post by:
Hi, I am a beginner in Python, and am wondering what is it about the indentation in Python, without which python scripts do not work properly. Why can't the indentation not so strict so as to give...
49
4064
IDE
by: Thomas Lindgaard | last post by:
Hello I am probably going to start a war now... but so be it :) I just want to hear what all you guys who eat pythons for breakfast use for python coding. Currently I use Kate, but I would...
12
2800
by: Thomas Bartkus | last post by:
Does anyone use emacs together with both WordStar key bindings and python mode? I'm afraid that Wordstar editing key commands are burned R/O into my knuckles! I would like to play with emacs...
113
5182
by: John Nagle | last post by:
The major complaint I have about Python is that the packages which connect it to other software components all seem to have serious problems. As long as you don't need to talk to anything outside...
1
1803
by: rshepard | last post by:
My editor is emacs in linux, and I have the python mode enabled. The two menus -- IM-Python and Python -- allow me to navigate within the loaded module and open execute buffers, among other things....
3
1664
by: Hadron | last post by:
Sorry to repeat, but I had to reinstall and lost all my news. I am looking for pointers on using emacs with python. I use emacs v 22.0.91 (Ubuntu snapshot). It comes with its own python mode....
7
2106
by: Michele Simionato | last post by:
I have noticed that the python-mode for Emacs that comes with the latest Ubuntu is missing the class browser. Moreover if works differently from the python-mode I was used to (for instance CTRL-c-c...
15
1578
by: skip | last post by:
If you're an Emacs user who has used both python-mode.el (the python mode code distributed with Python and XEmacs) and python.el (the python mode code distributed with GNU Emacs), I'd like to get...
0
6978
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7154
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6858
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7360
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5451
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4578
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3086
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1392
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
633
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.