如何配置多个 Ubuntu Python 安装以避免 App Engine 的 SSL 错误?

发布于 2024-08-31 03:36:05 字数 1448 浏览 9 评论 0原文

我有 Karmic Koala,它默认安装了 Python 2.6。

但是,我无法运行任何 Python App Engine 项目,因为它们需要 Python 2.5 和 python ssl。

为了安装 ssl,我首先安装了 python2.5-dev,同时遵循一些说明我在其他地方找到了

sudo apt-get install libssl-dev
sudo apt-get install python-setuptools
sudo apt-get install python2.5-dev 
sudo easy_install-2.5 pyopenssl

然而,我担心这对我的 Ubuntu 安装不利,因为当您在命令行中键入“python”时,Ubuntu 预计会看到 Python 2.6 版本。相反,它显示“2.5.5”。

但在这一切之后,App Engine 仍然无法工作。每当我尝试运行我的 Python 应用程序时,我都会继续收到与 SSL 相关的错误:

AttributeError: 'module' object has no attribute 'HTTPSHandler'

UPDATE1: Just Checked SSL 是否因这些命令而实际安装,方法是输入以下内容:

$ python2.5
Python 2.5.5 (r255:77872, Apr 29 2010, 23:59:20) 
[GCC 4.4.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import ssl
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named ssl
>>> 

如您所见,SSL 仍未安装,这解释了继续出现 App Engine 错误。

UPDATE2:

我尝试通过执行以下操作恢复到 Python 的原始默认版本:

sudo ln -s /usr/bin/python2.6 python

在我的 /usr/bin/local 文件夹中。

现在,当我在命令行中输入“python”时,我得到了 Python 2.6.4。

但这并不能解决我的 App Engine SSL 问题。

如果有人知道我如何才能摆脱这个困境,我将不胜感激。

I have Karmic Koala which has Python 2.6 installed by default.

However I can't run any Python App Engine projects because they require Python 2.5 and python ssl.

To install ssl I installed python2.5-dev first while following some instructions I found elsewhere.

sudo apt-get install libssl-dev
sudo apt-get install python-setuptools
sudo apt-get install python2.5-dev 
sudo easy_install-2.5 pyopenssl

However, I am afraid this is not good for my Ubuntu installation since Ubuntu expects to see version 2.6 of Python when you type 'python' on the command line. Instead, it says '2.5.5'.

But App Engine still doesn't work after all this. I continue to get an SSL-related error whenever I try to run my Python app:

AttributeError: 'module' object has no attribute 'HTTPSHandler'

UPDATE1: Just checked whether SSL actually installed as a result of those commands by typing this:

$ python2.5
Python 2.5.5 (r255:77872, Apr 29 2010, 23:59:20) 
[GCC 4.4.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import ssl
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named ssl
>>> 

As you can see, SSL is still not installed, which explains the continuing App Engine error.

UPDATE2:

I tried to revert to the original default version of Python by doing this:

sudo ln -s /usr/bin/python2.6 python

in my /usr/bin/local folder.

Now I get Python 2.6.4 when I type 'python' on the command line.

But this doesn't solve my App Engine SSL issue.

If anyone knows how I can dig myself out of this hole, I would appreciate it.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

眼泪也成诗 2024-09-07 03:36:05

您应该能够简单地安装 Ubuntu 的 Python 2.5 标准副本。 SSL 模块不是必需的 - 正如警告消息所示,如果您想要进行证书验证,则必须使用 SSL 模块,但仅此而已。

由于缺少“HTTPSHandler”而出现的错误可能是由于安装了没有 SSL 支持的 Python 版本(这独立于 ssl 模块,后者负责证书验证) - 再次尝试安装标准版本。

就版本选择而言,安装 Python 2.5 不应干扰默认系统版本 - 有一个选择器工具用于选择默认版本 - 因此您可以简单地使用“python2.5 dev_appserver.py”运行 dev_appserver 等。

You should be able to simply install Ubuntu's standard copy of Python 2.5. The SSL module isn't a requirement - as the warning message says, it's necessary if you want to do certificate validation, but that's all.

The error you're getting with a missing 'HTTPSHandler' is probably due to installing a version of Python that was compiled without SSL support (this is independent of the ssl module, which is what does certificate validation) - again, try installing the standard version.

As far as version selection goes, installing Python 2.5 shouldn't intefere with the default system version - there's a selector tool for choosing which version is the default - so you can simply run the dev_appserver etc with 'python2.5 dev_appserver.py'.

焚却相思 2024-09-07 03:36:05

在 Ubuntu 9.10 上,一个简单的 sudo aptitude install python2.5 就可以解决问题,然后只需在前面加上 python2.5 来调用脚本,如下所示:

python2.5 google_appengine/dev_appserver.py ...

但是在 Ubuntu 10.04 上,这是一个很大的不同,因为 Python 2.5 不再在存储库中......这意味着从源代码安装,并且由于必须这样做,我可以告诉你这并不有趣。它只是让您希望 Google 能够解决问题 757

无论是从存储库安装还是从源代码编译,安装 Python 2.5 的 SSL 支持都是相同的。只需下载SSL lib for 2.5,解压它,然后运行

sudo python2.5 setup.py install

编辑: 先前引用的问题的评论 51详细解释了如何在 Ubuntu 10.04 上安装 Python 2.5。正如您所看到的,这确实很麻烦!

On Ubuntu 9.10, a simple sudo aptitude install python2.5 should do the trick, then just call the scripts by prepending python2.5, like this:

python2.5 google_appengine/dev_appserver.py ...

On Ubuntu 10.04 however, this is a whole lot different since Python 2.5 is not in the repositories anymore... This means installing from source, and from having had to do it, I can tell you it's not funny. It just makes you wish Google would move on issue 757.

Installing the SSL support for Python 2.5 is the same, whether installed from the repos or compiled from source. Just download the SSL lib for 2.5, un-package it, and run

sudo python2.5 setup.py install

Edit: Comment 51 of previously cited issue explains in detail how to install Python 2.5 on Ubuntu 10.04. As you can see, this is really cumbersome!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文