Python和科学计算认证群组  - 讨论区

标题:Python(x,y)无法启动?

2010年07月05日 星期一 02:44

我在先后安装了Python(x,y)-2.6.2.0.exe和Python(x,y)-2.6.5.1.exe后,都不能启动Python(x,y),任务管理器中也没有看到相应的进程。网上也没搜索到类似的信息。请各位指教,谢谢!

我的系统:Winxp

2010年07月05日 星期一 06:37

我没有遇到这样的问题,不过有读者遇到过,他的解决办法是:将快捷方式所对应的pyw改名为py。你可以先试试看。

另外,你可以在命令行中运行python(x,y),这样可以查看它的出错信息。看能不能根据出错信息找到原因。

最后,xyhome.pyw只是一个方便启动其它程序的界面。其大部分功能都可以在Python(x,y)的开始菜单中找到直接启动的快捷方式。我一般是直接启动IPython或者Spyder进行开发。

2010年07月05日 星期一 17:01

我也是同样的问题,

我是这样解决的。

将快捷方式对应的pyw文件,更改后缀名为py,这样就可以了

但是会多出来一个命令行。

不过还好不会影响使用。

2010年07月05日 星期一 20:38

我把pyw改为py后还是不能启动Python(x,y)。

2010年07月05日 星期一 20:39

是不是之前安装过python程序,就会出现这种情况?

2010年07月05日 星期一 20:41

用命令行启动试试看,看看报错信息。

2010年07月05日 星期一 22:02

在命令行中执行xyhome.pyw,依然没有反应。

2010年07月05日 星期一 23:09

右键,Run In Interactive Mode

2010年07月05日 星期一 23:14

Plugin 'Python(x,y)' was found (Version: 2.6.5.1)
Plugin 'Python(x,y)' was found (DocPath: d:\Program Files\pythonxy\doc)
Plugin 'Python(x,y)' was found (Eclipse: d:\Program Files\pythonxy\eclipse)
Plugin 'Python(x,y)' was found (Workspace: C:\Documents and Settings\xx\My Doc
uments\Python)
Plugin 'Cython' was found (Version: 0.12.1)
Plugin 'QtEclipse' was found (Version: 1.5.2)
Plugin 'itk' was found (Version: 3.16)
Plugin 'Gnuplot' was found (Version: 1.8)
Plugin 'OpenGL' was found (Version: 3.0.1)
Plugin 'rst2pdf' was found (Version: 0.14.2)
Plugin 'formlayout' was found (Version: 1.0.9)
Plugin 'pywin32' was found (Version: 2.14)
Plugin 'WickedShell' was found (Version: 2.0.4)
Plugin 'PyQt4' was found (Version: 4.5.4)
Plugin 'IPython' was found (Version: 0.10)
Plugin 'xy' was found (Version: 1.1.2)
Plugin 'networkx' was found (Version: 1.1)
Plugin 'QtHelp' was found (Version: 4.5.2)
Plugin 'Qwt5' was found (Version: 5.2.0)
Plugin 'numexpr' was found (Version: 1.3.1)
Plugin 'pydicom' was found (Version: 0.9.4.2)
Plugin 'mdp' was found (Version: 2.5)
Plugin 'netcdf4' was found (Version: 0.9)
Plugin 'tables' was found (Version: 2.1.2)
Plugin 'cvxopt' was found (Version: 1.1.2)
Plugin 'PIL' was found (Version: 1.1.7)
Plugin 'py2exe' was found (Version: 0.6.9)
Plugin 'pyparallel' was found (Version: 0.2.0)
Plugin 'docutils' was found (Version: 0.6.0.1)
Plugin 'pygments' was found (Version: 1.3.1)
Plugin 'StartExplorer' was found (Version: 0.5.0)
Plugin 'vtk' was found (Version: 5.4.2)
Plugin 'mingw' was found (Version: 4.4.0)
Plugin 'gettext' was found (Version: 0.14.4.1)
Plugin 'pyserial' was found (Version: 2.4.0)
Plugin 'opencv' was found (Version: 2.1.0.wr1.0.1)
Plugin 'SendKeys' was found (Version: 0.3)
Plugin 'CDT' was found (Version: 6.0.2)
Plugin 'sympy' was found (Version: 0.6.7)
Plugin 'vpython' was found (Version: 5.32)
Plugin 'numpy' was found (Version: 1.3.0)
Plugin 'swig' was found (Version: 1.3.40)
Plugin 'Photran' was found (Version: 5.0.0)
Plugin 'vitables' was found (Version: 2.0)
Plugin 'xlwt' was found (Version: 0.7.2)
Plugin 'simplejson' was found (Version: 2.1.1)
Plugin 'pywinauto' was found (Version: 0.4.0)
Plugin 'PyWavelets' was found (Version: 0.2.0)
Plugin 'pylint' was found (Version: 0.20.0)
Plugin 'pp' was found (Version: 1.5.7)
Plugin 'matplotlib' was found (Version: 0.99.1)
Plugin 'SciTE' was found (Version: 2.11)
Plugin 'scipy' was found (Version: 0.7.1)
Plugin 'jinja2' was found (Version: 2.4.1)
Plugin 'pyreadline' was found (Version: 1.5)
Plugin 'reportlab' was found (Version: 2.4)
Plugin 'xydoc' was found (Version: 1.0.3)
Plugin 'console' was found (Version: 2.0.146)
Plugin 'gdal' was found (Version: 1.6.1)
Plugin 'psyco' was found (Version: 1.6)
Plugin 'Pydev' was found (Version: 1.5.6)
Plugin 'sphinx' was found (Version: 0.6.5)
Plugin 'xlrd' was found (Version: 0.7.1)
Plugin 'pyvisa' was found (Version: 1.3)
Plugin 'winpdb' was found (Version: 1.4.6)
Plugin 'spyder' was found (Version: 1.0.3)
Plugin 'scikits.timeseries' was found (Version: 0.91.3)
Plugin 'WinMerge' was found (Version: 2.12.4)
Plugin 'wxPython' was found (Version: 2.8.10.1)
Plugin 'nose' was found (Version: 0.11.3)
Plugin 'setuptools' was found (Version: 0.6.11)
Plugin 'h5py' was found (Version: 1.3.0)
Plugin 'EnthoughtToolSuite' was found (Version: 3.4.0)
Plugin 'mx' was found (Version: 3.1.3)
Plugin 'eclipse' was found (Version: 3.5.2)
Traceback (most recent call last):
  File "C:\Python26\Scripts\xyhome.pyw", line 21, in <module>
    xyhome.main()
  File "C:\Python26\lib\site-packages\xy\xyhome.pyw", line 642, in main
    form=MainWindow(options)
  File "C:\Python26\lib\site-packages\xy\xyhome.pyw", line 125, in __init__
    self.scanstartup()
  File "C:\Python26\lib\site-packages\xy\xyhome.pyw", line 531, in scanstartup
    default_startup()
  File "C:\Python26\lib\site-packages\xy\config.py", line 85, in default_startup

    filename=osp.join(STARTUP_PATH, CONF.get(None, 'startup'))
  File "C:\Python26\lib\ntpath.py", line 108, in join
    path += "\\" + b
UnicodeDecodeError: 'ascii' codec can't decode byte 0xcd in position 26: ordinal
 not in range(128)
>>> xyh
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'xyh' is not defined
>>> le
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'le' is not defined
>>> for
  File "<stdin>", line 1
    for
      ^
SyntaxError: invalid syntax
>>> le
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'le' is not defined
>>> sel
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'sel' is not defined
>>> le
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'le' is not defined
>>> def
  File "<stdin>", line 1
    def
      ^
SyntaxError: invalid syntax
>>> le
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'le' is not defined
>>>
>>> fil
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'fil' is not defined
>>> le
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'le' is not defined
>>> pat
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'pat' is not defined
>>> ode
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'ode' is not defined
>>>  in
  File "<stdin>", line 1
    in
    ^
IndentationError: unexpected indent
>>> xyh
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'xyh' is not defined
>>> le
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'le' is not defined
>>> for
  File "<stdin>", line 1
    for
      ^
SyntaxError: invalid syntax
>>> le
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'le' is not defined
>>> sel
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'sel' is not defined
>>> le
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'le' is not defined
>>> def
  File "<stdin>", line 1
    def
      ^
SyntaxError: invalid syntax
>>> le
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'le' is not defined
>>>
>>> fil
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'fil' is not defined
>>> le
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'le' is not defined
>>> pat
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'pat' is not defined
>>> ode
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'ode' is not defined
>>>  in
  File "<stdin>", line 1
    in
    ^
IndentationError: unexpected indent
>>>

2010年07月05日 星期一 23:16

右键,Run In Interactive Mode ,有如上错误信息。

2010年07月06日 星期二 06:43

根据下面的报错信息,我猜你的Windows用户文件夹有中文

filename=osp.join(STARTUP_PATH, CONF.get(None, 'startup')) 
  File "C:\Python26\lib\ntpath.py", line 108, in join 
    path += "\\" + b 
UnicodeDecodeError: 'ascii' codec can't decode byte 0xcd in position 26: ordinal 

在Python交互环境中输入下面的语句,看看你的用户文件夹是什么:

>>> import os.path as p

>>> p.expanduser("~")

我想可以通过环境变量HOME修改此文件夹,不过更好的解决办法是修改

filename=osp.join(STARTUP_PATH, CONF.get(None, 'startup')) 

使它使用合适的文字编码。等我有空试试看。

2010年07月06日 星期二 08:14

UnicodeDecodeError: 'ascii' codec can't decode byte 0xcd in position 26: ordinal
 not in range(128)
>>> import os.path as p
>>> p.expanduser("~")
'C:\\Documents and Settings\\\xcd\xf5\xc0\xa4'
>>>

 

怎样修改环境变量HOME,怎样使用 filename=osp.join(STARTUP_PATH, CONF.get(None, 'startup'))  ?

2010年07月06日 星期二 12:57

我安装pythonxy的时候是把本机的phton2.6给卸载了的。

改名以后就可以正常运行了。

不过大多的功能都可以直接在开始菜单下面找到。

不能运行这个快捷方式,也是没有什么关系的

2010年07月06日 星期二 18:33

找到原因和解决办法了。因为WindowXP的环境变量不是使用Unicode,因此通过环境变量读入用户文件夹时需要指定编码,具体解决办法如下:

编辑
c:\python26\lib\site-packages\xy\userconfig.py

的get_home_dir()函数,将57行左右的:

if path:
   return path

改为:

if path:
   return path.decode("cp936")

或者
if path:
   import locale
   return path.decode( locale.getpreferredencoding() )

2010年07月06日 星期二 22:26

Traceback (most recent call last):
  File "C:\Python26\Scripts\xyhome.pyw", line 20, in <module>
    from xy import xyhome
  File "C:\Python26\lib\site-packages\xy\xyhome.pyw", line 28, in <module>
    from xy.config import (CONF, STARTUP_PATH, LOG_PATH, PLUGINS, XY_VERSION,
  File "C:\Python26\lib\site-packages\xy\config.py", line 33, in <module>
    CONF = UserConfig('xy', defaults=DEFAULTS, version=__version__, subfolder='.
xy')
  File "C:\Python26\lib\site-packages\xy\userconfig.py", line 94, in __init__
    self.load_from_ini()
  File "C:\Python26\lib\site-packages\xy\userconfig.py", line 120, in load_from_
ini
    self.read(self.filename())
  File "C:\Python26\lib\site-packages\xy\userconfig.py", line 149, in filename
    folder = osp.join(folder, self.subfolder)
  File "C:\Python26\lib\ntpath.py", line 96, in join
    assert len(path) > 0
TypeError: object of type 'NoneType' has no len()
>>>

两种方法都试了,还是有错误。

2010年07月06日 星期二 22:36

在Python命令行输入

>>> import xy.userconfig as u

>>> u.get_home_dir()

看看是什么结果?

报错信息的意思是说get_home_dir()返回的是None,不应该啊。

2010年07月06日 星期二 22:47

正在重装,RY大哥请等几分钟!

2010年07月06日 星期二 23:07

双击Python(x,y)还是不能启动,但是右键,Run In Interactive Mode ,可以启动。

 

2010年07月06日 星期二 23:14

那就和邹建遇到的问题一样了,将pyw扩展名修改成py,应该也可以启动。就是要带那个命令行窗口。

2010年07月06日 星期二 23:20

很奇怪,现在将get_home_dir()函数还原,右键Run In Interactive Mode 也可以启动Python(x,y)。

如果用邹建的方法,将pyw改为py,则双击Python(x,y)也可以启动。

2010年07月06日 星期二 23:30

RY大哥的操作系统应该是英文版的吧?

如下红色区域有误,请重新填写。

    你的回复:

    请 登录 后回复。还没有在Zeuux哲思注册吗?现在 注册 !

    Zeuux © 2024

    京ICP备05028076号