473,219 Members | 1,431 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,219 software developers and data experts.

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 12224

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
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
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
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
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
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
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
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
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
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...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...

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.