Python 在不同 linux 版本上可执行 运行
Python executable running on different linux versions
我需要编写一个最终会在 CentOS 上 运行ning 的程序(版本 6.3 - 它是一个安全设备,但我有根访问权限)
我在 Ubuntu 中安装了一个开发环境,并使用 pyinstaller 创建了一个可执行文件。在 PyCharm 中,我可以在 python 版本 2.7 和 3.6 之间 select - 我尝试了两个版本并创建了 exe。
该程序在 Ubuntu 上运行良好,但不幸的是在 CentOS 下运行不佳
CentOS 显示 Python 版本 2.66
问题:
- 它应该在一般情况下工作吗?
- 我收到错误-(缺少库)(但文件存在):
“./ICC: /lib64/libc.so.6: 找不到版本 `GLIBC_2.14'(/tmp/_MEIoHOzeE/libz.so.1 要求)” - 我假设版本不匹配?
在 CentOS (2.66) 上安装 python 版本很重要吗(我希望可执行文件包含所需的一切?)
我使用了带有选项“--onefile”的 pyinstaller
我在源代码的第一行添加了“#!/usr/bin/python”
如果我 运行 the.py 文件(源代码)出现多个错误:
./ICC.py:第 1 行:导入:找不到命令
./ICC.py:第 2 行:导入:找不到命令
./ICC.py:第 13 行:版本:找不到命令
./ICC.py:第 24 行:try:: 未找到命令
./ICC.py: 第 25 行:意外标记 ('
./ICC.py: line 25:
附近的语法错误 logfile = open ("/tmp/icm-log.txt","w")'
(相同的代码 运行 在 ubuntu 上没问题,猜想在较新的 python 版本中情况发生了变化,这是有道理的)
需要用Python2.66写程序吗?我需要将开发转移到 CentOS 吗?
我无法在 CentOS 上升级 Python,因为它可能会破坏其他东西
关于如何使这项工作有效的任何建议、想法和提示。
TIA 马丁
当您使用 PyInstaller 创建可执行二进制文件时,您必须在目标机器或目标环境上执行此操作。
The output of PyInstaller is specific to the active operating system and the active version of Python. This means that to prepare a distribution for:
- a different OS
- a different version of Python
- a 32-bit or 64-bit OS
you run PyInstaller on that OS, under that version of Python. The Python interpreter that executes PyInstaller is part of the bundle, and it is specific to the OS and the word size."
更多信息可用here
我需要编写一个最终会在 CentOS 上 运行ning 的程序(版本 6.3 - 它是一个安全设备,但我有根访问权限) 我在 Ubuntu 中安装了一个开发环境,并使用 pyinstaller 创建了一个可执行文件。在 PyCharm 中,我可以在 python 版本 2.7 和 3.6 之间 select - 我尝试了两个版本并创建了 exe。 该程序在 Ubuntu 上运行良好,但不幸的是在 CentOS 下运行不佳 CentOS 显示 Python 版本 2.66
问题: - 它应该在一般情况下工作吗? - 我收到错误-(缺少库)(但文件存在): “./ICC: /lib64/libc.so.6: 找不到版本 `GLIBC_2.14'(/tmp/_MEIoHOzeE/libz.so.1 要求)” - 我假设版本不匹配?
在 CentOS (2.66) 上安装 python 版本很重要吗(我希望可执行文件包含所需的一切?)
我使用了带有选项“--onefile”的 pyinstaller
我在源代码的第一行添加了“#!/usr/bin/python”
如果我 运行 the.py 文件(源代码)出现多个错误:
./ICC.py:第 1 行:导入:找不到命令 ./ICC.py:第 2 行:导入:找不到命令 ./ICC.py:第 13 行:版本:找不到命令 ./ICC.py:第 24 行:try:: 未找到命令 ./ICC.py: 第 25 行:意外标记
(' ./ICC.py: line 25:
附近的语法错误 logfile = open ("/tmp/icm-log.txt","w")'
(相同的代码 运行 在 ubuntu 上没问题,猜想在较新的 python 版本中情况发生了变化,这是有道理的)
需要用Python2.66写程序吗?我需要将开发转移到 CentOS 吗?
我无法在 CentOS 上升级 Python,因为它可能会破坏其他东西
关于如何使这项工作有效的任何建议、想法和提示。
TIA 马丁
当您使用 PyInstaller 创建可执行二进制文件时,您必须在目标机器或目标环境上执行此操作。
The output of PyInstaller is specific to the active operating system and the active version of Python. This means that to prepare a distribution for:
- a different OS
- a different version of Python
- a 32-bit or 64-bit OS
you run PyInstaller on that OS, under that version of Python. The Python interpreter that executes PyInstaller is part of the bundle, and it is specific to the OS and the word size."
更多信息可用here