python - 将 Python 安装到主目录

标签 python python-2.7

<分区>

我正在使用 Python 2.6.6,在使用 urllib.request.build_opener(...).open(request)

通过 https 连接时出现错误
urlopen error [Errno 1] _ssl.c:504: error:14077438:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert internal error

我发现 TLS SNI 有问题,它是在 2.7.9 版本中添加的。我尝试了 pyOpenSSL(只是将它复制到我的 *.py 脚本目录)但没有成功。

不幸的是,我没有 root 访问权限,因此无法升级 python 或安装任何软件包。我可以在主目录中“安装”python 2.7.9 并使用该版本运行脚本吗?

最佳答案

假设您的服务器安装了您可以使用的编译器 (GCC),则可以安装任何 Python 版本。

Download Python source code here .应用基本的 UNIX 命令知识来下载 Gzip 压缩文件并将其解压缩到主目录中的文件夹中。 Follow instructions to compile Python .

请注意,服务器必须安装所需的 OpenSSL 库,否则您将无法获得 SSL 支持。如果您需要从头开始引导整个堆栈(所有库、编译器等),这是不可行的,在这种情况下,我建议您转移到另一个服务器提供商。

另见:

https://serverfault.com/questions/353128/recompiling-python-with-ssl-support-on-ubuntu

关于python - 将 Python 安装到主目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30903989/

相关文章:

python - 无法 pip 安装 scipy、mlxtend 和数学库

python - 如何在 Mac 上从 $PATH 中删除特定路径

Python 的 .text : Couldn't get it to work

python - 鼠标事件中的 tkinter wait_variable

python - 从 Python 登录服务器和 MySQL

Python 覆盖我的文件并且找不到其他文件

python - Django:如何使用参数重定向

python - 使用 MySQLdb 插入 MySQL - python

python - 找出列表中不存在的条目

django - 导入错误 : cannot import name SortedDict - only on Python 2. 7,而不是 2.6