在同一平台上使用不同版本的python的问题 [英] problem with different version of python on the same platform

查看:206
本文介绍了在同一平台上使用不同版本的python的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先我在我的电脑上安装python 3.3(操作系统:Windows 7 32位),然后我在同一平台上安装python 2.7。

现在python 2.7工作正常,但python 3.3出现以下错误。

(切换纯文本)

C:\Python33> python

致命Python错误:Py_Initialize:无法加载文件系统编解码器

文件C:\Python27 \lib \ encodings\__init __。py,第123行

引发CodecRegistryError,\

^

语法错误:语法无效



C:\Python33>

解决方案

< blockquote>受欢迎程度以及相当轻量级的Python确实导致了这样的情况,即使用户从未使用过的Python本身也已经有两个或更多不同版本,只是因为它被几个不同的应用程序和系统使用。



在Linux上,这通常不是问题;而且通常只使用一个版本的Python。在Windows上,这是一个潜在的问题(无论如何都有一些相同的冗余版本不是一个完美的情况),但它不应该成为一个真正的问题。毕竟,你已经拥有的几个应用程序从不搞乱不同版本,是吗? :-)



您应该注意简单的事情:不要依赖于访问Python文件(或任何其他文件)常用路径,例如PATH环境变量中规定的路径。而是根据应用程序的位置计算Python文件的路径。根据您提供的信息,我无法向您提供更多详细信息,但我希望您有这个想法。



-SA


first i install python 3.3 on my pc (OS : Windows 7 32bit) and then i install python 2.7 on the same platform.
Now python 2.7 works fine but python 3.3 gives the following error.
(Toggle Plain Text)
C:\Python33>python
Fatal Python error: Py_Initialize: unable to load the file system codec
File "C:\Python27\lib\encodings\__init__.py", line 123
raise CodecRegistryError,\
^
SyntaxError: invalid syntax

C:\Python33>

解决方案

The popularity, as well as quite a light weight of Python really lead to the situation when even the users never using Python itself already have two or more different versions of it, just because it is used by several different applications and systems.

On Linux, this is usually not a problem; and it is very typically that only one version of Python is actually used. On Windows, it is a potential problem (having some redundant version of the same thing is not a perfect situation anyway), but it should not become a real problem. After all, several application programs you already have never mess up different versions, do they? :-)

You should take care about on simple thing: don't rely on the access to the Python files (or any other files, for that matter) through a commonly accessed path, such as prescribed in the PATH environment variable. Instead, calculate the path to Python files based on the location of your application program. I cannot give you more detail based on the information you provided, but I hope you got the idea.

—SA


这篇关于在同一平台上使用不同版本的python的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆