Pyflakes and IPython does not work for Emacs on Windows?

D

Dsrt Egle

Hi,

With Python on Windows, I tried to use Emacs as the programming
environment. For syntax checking I installed pyflakes, but flymake
always reports "fail to launch. No such file or directory: pyflakes"
when opening a Python file. Is pyflakes not for Windows? What Python
syntax checking tools work for Emacs on Windows?

I can't invoke IPython by Emacs on Windows, either. Looks ipyhon.el
only works for Linux?

Thanks for your comments
 
B

Benjamin Kaplan

Hi,

With Python on Windows, I tried to use Emacs as the programming
environment. For syntax checking I installed pyflakes, but flymake
always reports "fail to launch. No such file or directory: pyflakes"
when opening a Python file. Is pyflakes not for Windows? What Python
syntax checking tools work for Emacs on Windows?

I can't invoke IPython by Emacs on Windows, either. Looks ipyhon.el
only works for Linux?

I don't use emacs but my guess would be that this is a path issue. In
Linux, most executables, like ipython, are put into /usr/bin or
/usr/local/bin. Both ipod those locations are on the shell's path-the
places it look s when you don't specify the full path of a program. On
Windows, user-installed programs don't typically get put on the path.
Check the path to make sure the directory is on there. It's probably a
similar issue with pyflakes- you didn't put the file in the place
where flatmate looks for it.
 
D

Dsrt Egle

I don't use emacs but my guess would be that this is a path issue. In
Linux, most executables, like ipython, are put into /usr/bin or
/usr/local/bin. Both ipod those locations are on the shell's path-the
places it look s when you don't specify the full path of a program. On
Windows, user-installed programs don't typically get put on the path.
Check the path to make sure the directory is on there. It's probably a
similar issue with pyflakes- you didn't put the file in the place
where flatmate looks for it.


Thanks for your reply, Ben. Actually I have the paths "C:\Python25;C:
\Python25\Scripts" in the %PATH% variable, and the %PYTHONPATH% has
the following:

C:\Python25\Lib\site-packages\pyflakes;C:\Python25\Lib\site-packages
\Pymacs;C:\Python25\Lib\site-packages\rope;C:\Python25\Lib\site-
packages\ropemacs;C:\Python25\Lib\site-packages\ropemode

Pymacs, rope, ropemacs, ropemode all work in Emacs, except pyflakes.

Looking at the file C:\Python25\Lib\site-packages\pyflakes-0.4.0-
py2.5.egg\EGG-INFO\scripts\pyflakes, it shows


#!C:\Python25\python.exe

from pyflakes.scripts.pyflakes import main
main()


So this script needs to trigger Python interpreter to run. I can
successfully run pyflakes by manually triggering Python like this:

C:\>python C:\Python25\Lib\site-packages\pyflakes-0.4.0-py2.5.egg\EGG-
INFO\scripts\pyflakes test_new_lib.py
test_new_lib.py:13: invalid syntax
sa.CoreObj.



So pyflakes is running correctly. But it seems Emacs treats pyflakes
as an executable program instead of Python script. I include the
following in my .emacs file for pyflakes:



;;===== PyFlakes
;; code checking via pyflakes+flymake

(when (load "flymake" t)
(defun flymake-pyflakes-init ()
(let* ((temp-file (flymake-init-create-temp-buffer-copy
'flymake-create-temp-inplace))
(local-file (file-relative-name
temp-file
(file-name-directory buffer-file-name))))
(list "pyflakes" (list local-file))))

(add-to-list 'flymake-allowed-file-name-masks
'("\\.py\\'" flymake-pyflakes-init)))

(add-hook 'find-file-hook 'flymake-find-file-hook)



What should I do to configure Emacs to make pyflakes working? Thank
you!
 
T

Thomas Jollans

Thanks for your reply, Ben. Actually I have the paths "C:\Python25;C:
\Python25\Scripts" in the %PATH% variable, and the %PYTHONPATH% has
the following:

[...]

Looking at the file C:\Python25\Lib\site-packages\pyflakes-0.4.0-
py2.5.egg\EGG-INFO\scripts\pyflakes, it shows

C:\Python25\Lib\site-packages\pyflakes-0.4.0-py2.5.egg\EGG-INFO\scripts\
doesn't appear to be on your PATH then? Also, the file "pyflakes" won't be
executable without a file extension on Windows. I suggest you try either
creating a pyflakes.bat file somewhere on your PATH, or using the pyflakes
script as pyflakes.py, locates somewhere on the PATH (will this work? I'm not
sure)
 
D

Dsrt Egle

There don't appear to be a lot of ipython.el users on Windows.
You may have better look on an emacs list since there appear to be
some configuration issues.
Doeshttps://bugs.launchpad.net/ipython/+bug/290228    help at all?

Hi David,

This fix seems not working for me. I am using IPython 0.10, Python
2.5, and EmacsW32 23.1. When I invoke python-shell in Emacs, IPython
crashes with the following long debugging information:


ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (14, 0))

---------------------------------------------------------------------------
TypeError Python 2.5.2: C:
\Python25\python.exe
Thu Sep 30 14:00:08
2010
A problem occured executing Python code. Here is the sequence of
function
calls leading up to the error, with the most recent (innermost) call
last.

c:\Python25\Scripts\ipython-script.py in <module>()
1
2
3
4
5
6
7
----> 8
global load_entry_point = <function load_entry_point at
0x00B5A4B0>
9 #!C:\Python25\python.exe
10 # EASY-INSTALL-ENTRY-SCRIPT:
'ipython==0.10','console_scripts','ipython'
11 __requires__ = 'ipython==0.10'
12 import sys
13 from pkg_resources import load_entry_point
14
15 sys.exit(
16 load_entry_point('ipython==0.10', 'console_scripts',
'ipython')()
17 )
18
19
20
21
22
23
24
25
26
27
28
29
30
31

C:\Python25\lib\site-packages\ipython-0.10-py2.5.egg\IPython\ipapi.pyc
in launch_new_instance(user_ns=None, shellclass=None)
541
542 def check_hotname(self,name):
543 if name in self.hotnames:
544 self.debug_stack( "HotName '%s' caught" % name)
545
546
547 def launch_new_instance(user_ns = None,shellclass = None):
548 """ Make and start a new ipython instance.
549
550 This can be called even without having an already
initialized
551 ipython session running.
552
553 This is also used as the egg entry point for the 'ipython'
script.
554
555 """
--> 556 ses = make_session(user_ns,shellclass)
557 ses.mainloop()
558
559
560 def make_user_ns(user_ns = None):
561 """Return a valid user interactive namespace.
562
563 This builds a dict with the minimal information needed to
operate as a
564 valid IPython user namespace, which you can pass to the
various embedding
565 classes in ipython.
566
567 This API is currently deprecated. Use
ipapi.make_user_namespaces() instead
568 to make both the local and global namespace objects
simultaneously.
569
570 :parameters:
571 user_ns : dict-like, optional

C:\Python25\lib\site-packages\ipython-0.10-py2.5.egg\IPython\ipapi.pyc
in make_session(user_ns=None, shellclass=None)
669
670 def make_session(user_ns = None, shellclass = None):
671 """Makes, but does not launch an IPython session.
672
673 Later on you can call obj.mainloop() on the returned
object.
674
675 Inputs:
676
677 - user_ns(None): a dict to be used as the user's
namespace with initial
678 data.
679
680 WARNING: This should *not* be run when a session exists
already."""
681
682 import IPython.Shell
683 if shellclass is None:
--> 684 return IPython.Shell.start(user_ns)
685 return shellclass(user_ns = user_ns)
686
687
688
689
690
691
692
693
694
695
696
697
698
699

C:\Python25\lib\site-packages\ipython-0.10-py2.5.egg\IPython\Shell.pyc
in start(user_ns=None)
1226 th_mode = special_opts.pop()
1227 except KeyError:
1228 th_mode = 'tkthread'
1229 return th_shell[th_mode]
1230
1231
1232 # This is the one which should be called by external code.
1233 def start(user_ns = None):
1234 """Return a running shell instance, dealing with threading
options.
1235
1236 This is a factory function which will instantiate the
proper IPython shell
1237 based on the user's threading choice. Such a selector is
needed because
1238 different GUI toolkits require different thread handling
details."""
1239
1240 shell = _select_shell(sys.argv)
-> 1241 return shell(user_ns = user_ns)
1242
1243 # Some aliases for backwards compatibility
1244 IPythonShell = IPShell
1245 IPythonShellEmbed = IPShellEmbed
1246 #************************ End of file <Shell.py>
***************************
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256

C:\Python25\lib\site-packages\ipython-0.10-py2.5.egg\IPython\Shell.pyc
in __init__(self=<IPython.Shell.IPShell instance at 0x00ABFDA0>,
argv=None, user_ns=None, user_global_ns=None, debug=1,
shell_class=<class 'IPython.iplib.InteractiveShell'>)
58 # Default timeout for waiting for multithreaded shells (in
seconds)
59 GUI_TIMEOUT = 10
60
61
#-----------------------------------------------------------------------------
62 # This class is trivial now, but I want to have it in to
publish a clean
63 # interface. Later when the internals are reorganized, code
that uses this
64 # shouldn't have to change.
65
66 class IPShell:
67 """Create an IPython instance."""
68
69 def
__init__(self,argv=None,user_ns=None,user_global_ns=None,
70 debug=1,shell_class=InteractiveShell):
71 self.IP = make_IPython(argv,user_ns=user_ns,
72 user_global_ns=user_global_ns,
---> 73
debug=debug,shell_class=shell_class)
global that = undefined
global gets = undefined
global prepended = undefined
global to = undefined
global all = undefined
global calls = undefined
global so = undefined
global header = undefined
global used = undefined
74
75 def mainloop(self,sys_exit=0,banner=None):
76 self.IP.mainloop(banner)
77 if sys_exit:
78 sys.exit()
79
80
#-----------------------------------------------------------------------------
81 def kill_embedded(self,parameter_s=''):
82 """%kill_embedded : deactivate for good the current
embedded IPython.
83
84 This function (after asking for confirmation) sets an
internal flag so that
85 an embedded IPython will never activate again. This is
useful to
86 permanently disable a shell that is being called inside a
loop: once you've
87 figured out what you needed from it, you may then kill it
and the program
88 will then continue to run without the interactive shell
interfering again.

C:\Python25\lib\site-packages\ipython-0.10-py2.5.egg\IPython
\ipmaker.pyc in make_IPython(argv=[r'c:\Python25\Scripts\ipython-
script.py', '-i'], user_ns=None, user_global_ns=None, debug=1,
rc_override=None, shell_class=<class
'IPython.iplib.InteractiveShell'>, embedded=False, **kw={})
755 IP_rc.banner = 0
756 if IP_rc.banner:
757 BANN_P = IP.BANNER_PARTS
758 else:
759 BANN_P = []
760
761 if IP_rc.profile: BANN_P.append('IPython profile: %s\n' %
IP_rc.profile)
762
763 # add message log (possibly empty)
764 if msg.summary: BANN_P.append(msg.summary)
765 # Final banner is a string
766 IP.BANNER = '\n'.join(BANN_P)
767
768 # Finalize the IPython instance. This assumes the rc
structure is fully
769 # in place.
--> 770 IP.post_config_initialization()
771
772 return IP
773 #************************ end of file <ipmaker.py>
**************************
774
775
776
777
778
779
780
781
782
783
784
785

C:\Python25\lib\site-packages\ipython-0.10-py2.5.egg\IPython\iplib.pyc
in post_config_initialization(self=<IPython.iplib.InteractiveShell
object at 0x00B71CB0>)
847 This is called after the configuration files have been
processed to
848 'finalize' the initialization."""
849
850 rc = self.rc
851
852 # Object inspector
853 self.inspector =
OInspect.Inspector(OInspect.InspectColors,
854
PyColorize.ANSICodeColors,
855 'NoColor',
856
rc.object_info_string_level)
857
858 self.rl_next_input = None
859 self.rl_do_indent = False
860 # Load readline proper
861 if rc.readline:
--> 862 self.init_readline()
863
864 # local shortcut, this is used a LOT
865 self.log = self.logger.log
866
867 # Initialize cache, set in/out prompts and printing
system
868 self.outputcache = CachedOutput(self,
869 rc.cache_size,
870 rc.pprint,
871 input_sep =
rc.separate_in,
872 output_sep =
rc.separate_out,
873 output_sep2 =
rc.separate_out2,
874 ps1 = rc.prompt_in1,
875 ps2 = rc.prompt_in2,
876 ps_out =
rc.prompt_out,
877 pad_left =
rc.prompts_pad_left)

C:\Python25\lib\site-packages\ipython-0.10-py2.5.egg\IPython\iplib.pyc
in init_readline(self=<IPython.iplib.InteractiveShell object at
0x00B71CB0>)
1476 if not readline.uses_libedit:
1477 for rlcommand in
self.rc.readline_parse_and_bind:
1478 #print "loading rl:",rlcommand # dbg
1479 readline.parse_and_bind(rlcommand)
1480
1481 # Remove some chars from the delimiters list. If
we encounter
1482 # unicode chars, discard them.
1483 delims =
readline.get_completer_delims().encode("ascii", "ignore")
1484 delims = delims.translate(string._idmap,
1485
self.rc.readline_remove_delims)
1486 readline.set_completer_delims(delims)
1487 # otherwise we end up with a monster history after
a while:
1488 readline.set_history_length(1000)
1489 try:
1490 #print '*** Reading readline history' # dbg
-> 1491 readline.read_history_file(self.histfile)
1492 except IOError:
1493 pass # It doesn't exist yet.
1494
1495 atexit.register(self.atexit_operations)
1496 del atexit
1497
1498 # Configure auto-indent for all platforms
1499 self.set_autoindent(self.rc.autoindent)
1500
1501 def ask_yes_no(self,prompt,default=True):
1502 if self.rc.quiet:
1503 return True
1504 return ask_yes_no(prompt,default)
1505
1506 def new_main_mod(self,ns=None):

C:\Python25\lib\site-packages\pyreadline\rlmain.pyc in
read_history_file(self=<pyreadline.rlmain.Readline object at
0x00DDFCD0>, filename=u'C:\\Home\\_ipython\\history')
168
169 def set_history_length(self, length):
170 '''Set the number of lines to save in the history
file.
171
172 write_history_file() uses this value to truncate the
history file
173 when saving. Negative values imply unlimited history
file size.
174 '''
175 self._history.set_history_length(length)
176
177 def clear_history(self):
178 '''Clear readline history'''
179 self._history.clear_history()
180
181 def read_history_file(self, filename=None):
182 '''Load a readline history file. The default filename
is ~/.history.'''
--> 183 self._history.read_history_file(filename)
184
185 def write_history_file(self, filename=None):
186 '''Save a readline history file. The default filename
is ~/.history.'''
187 self._history.write_history_file(filename)
188
189 #Completer functions
190
191 def set_completer(self, function=None):
192 '''Set or remove the completer function.
193
194 If function is specified, it will be used as the new
completer
195 function; if omitted or None, any completer function
already
196 installed is removed. The completer function is called
as
197 function(text, state), for state in 0, 1, 2, ...,
until it returns a
198 non-string value. It should return the next possible
completion

C:\Python25\lib\site-packages\pyreadline\lineeditor\history.pyc in
read_history_file(self=<pyreadline.lineeditor.history.LineHistory
object at 0x00DDFE10>, filename=u'C:\\Home\\_ipython\\history')
55
56
history_length=property(get_history_length,set_history_length)
57
history_cursor=property(get_history_cursor,set_history_cursor)
58
59 def clear_history(self):
60 '''Clear readline history.'''
61 self.history[:] = []
62 self.history_cursor = 0
63
64 def read_history_file(self, filename=None):
65 '''Load a readline history file.'''
66 if filename is None:
67 filename=self.history_filename
68 try:
69 for line in open(filename, 'r'):
---> 70
self.add_history(lineobj.ReadLineTextBuffer(ensure_unicode(line.rstrip())))
global n = undefined
global Xd = undefined
global S = undefined
global NR = undefined
global i = undefined
global R2 = undefined
global R = undefined
global t = undefined
global history_search_forwardt = undefined
global history_search_backwardt = undefined
global joinR2 = undefined
global maxR = undefined
global mint = undefined
global IndexError = undefined
global RX = undefined
global partialt = undefined
global hcstartt = undefined
global hct = undefined
global ht = undefined
global result = undefined
global s = undefined
global C = undefined
global Python25 = undefined
global lib = undefined
global site = undefined
global packages = undefined
global pyreadline = <module 'pyreadline' from 'C:\Python25\lib
\site-packages\pyreadline\__init__.pyc'>
global lineeditor = undefined
global history.pyt = undefined
global _search = undefined
global I = undefined
global c = undefined
global d = undefined
global Search = undefined
global forward = undefined
global through = undefined
global the = undefined
global history = undefined
global string = <module 'string' from 'C:\Python25\lib
\string.pyc'>
global of = undefined
global characters = undefined
global between = undefined
global start = undefined
global current = undefined
line = 'import sys\n'
global point.This = undefined
global a = undefined
global non = undefined
global incremental = undefined
global search.By = undefined
global default = undefined
global this = undefined
global command = undefined
global unbound.i = undefined
global Rj = undefined
global Re = undefined
global q = undefined
global history.pyR_ = undefined
global backward = undefined
global Rk = undefined
global history.pyR = undefined
global N = undefined
global propertyR = undefined
global R4 = undefined
global R5 = undefined
global R7 = undefined
global R8 = undefined
global RC = undefined
global RD = undefined
global R_ = undefined
global s.t = undefined

Press enter to exit: global __main__t = undefined
global aaaat = undefined
global aabat = undefined
global aacat = undefined
global akcat = undefined
global bbbt = undefined
global ako = undefined
global ret = undefined
global operatorRS = undefined
global sysR = undefined
global pyreadline.unicode_helperR = undefined
global modulesR = undefined
global exceptionst = undefined
global ExceptionR = undefined
global pyreadline.loggerR = undefined
global FalseR9 = undefined
global objectR = undefined
global RLR = undefined
global history.pys = undefined
global module = undefined
71 except IOError:
72 self.history = []
73 self.history_cursor = 0
74
75 def write_history_file(self, filename=None):
76 '''Save a readline history file.'''
77 if filename is None:
78 filename=self.history_filename
79 fp = open(filename, 'wb')
80 for line in self.history[-self.history_length:]:
81 fp.write(ensure_str(line.get_line_text()))
82 fp.write('\n')
83 fp.close()
84
85

C:\Python25\lib\site-packages\pyreadline\unicode_helper.pyc in
ensure_unicode(text='import sys')
5 # Distributed under the terms of the BSD License. The full
license is in
6 # the file COPYING, distributed as part of this software.
7
#*****************************************************************************
8 import sys
9
10 try:
11 pyreadline_codepage=sys.stdout.encoding
12 except AttributeError: #This error occurs when pdb
imports readline and doctest has replaced
13 #stdout with stdout collector
14 pyreadline_codepage="ascii" #assume ascii codepage
15
16
17 def ensure_unicode(text):
18 """helper to ensure that text passed to WriteConsoleW is
unicode"""
19 if isinstance(text, str):
---> 20 return text.decode(pyreadline_codepage, "replace")
21 return text
22
23 def ensure_str(text):
24 """Convert unicode to str using pyreadline_codepage"""
25 if isinstance(text, unicode):
26 return text.encode(pyreadline_codepage, "replace")
27 return text
28
29
30
31
32
33
34
35

TypeError: decode() argument 1 must be string, not None

**********************************************************************

Oops, IPython crashed. We do our best to make it stable, but...

A crash report was automatically generated with the following
information:
- A verbatim copy of the crash traceback.
- A copy of your input history during this session.
- Data on your current IPython configuration.

It was left in the file named:
'C:\Home\_ipython\IPython_crash_report.txt'
If you can email this file to the developers, the information in it
will help
them in understanding and correcting the problem.

You can mail it to: Fernando Perez at (e-mail address removed)
with the subject 'IPython Crash Report'.

If you want to do it now, the following command will work (under
Unix):
mail -s 'IPython Crash Report' (e-mail address removed) < C:\Home\_ipython
\IPython_crash_report.txt

To ensure accurate tracking of this issue, please file a report about
it at:
https://bugs.launchpad.net/ipython/+filebug
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top