找不到独立于平台的库

找不到独立于平台的库
After this operation, 0 B of additional disk space will be used.
Get:1 http://us-east-1.ec2.archive.ubuntu.com/ubuntu/ trusty/main python3 amd64 3.4.0-0ubuntu2 [8,666 B]
Fetched 8,666 B in 0s (53.3 kB/s)
Setting up base-files (7.2ubuntu5.5) ...
Installing new version of config file /etc/issue ...
Installing new version of config file /etc/issue.net ...
Installing new version of config file /etc/lsb-release ...
Installing new version of config file /etc/os-release ...
Processing triggers for plymouth-theme-ubuntu-text (0.8.8-0ubuntu17.1) ...
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportError: No module named 'encodings'
Aborted (core dumped)
update-initramfs: deferring update (trigger activated)
Processing triggers for initramfs-tools (0.103ubuntu4.2) ...
update-initramfs: Generating /boot/initrd.img-3.13.0-74-generic
(Reading database ... 126647 files and directories currently installed.)
Preparing to unpack .../python3_3.4.0-0ubuntu2_amd64.deb ...
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportError: No module named 'encodings'
Aborted (core dumped)
dpkg: warning: subprocess old pre-removal script returned error exit status 134
dpkg: trying script from the new package instead ...
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportError: No module named 'encodings'
Aborted (core dumped)
dpkg: error processing archive /var/cache/apt/archives/python3_3.4.0-0ubuntu2_amd64.deb (--unpack):
 subprocess new pre-removal script returned error exit status 134
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportError: No module named 'encodings'
Aborted (core dumped)
dpkg: error while cleaning up:
 subprocess installed post-installation script returned error exit status 134
E: Sub-process /usr/bin/dpkg returned an error code (1)

答案1

该问题可能是由于您的系统中安装了多个 Python。您有两个变量 PYTHONPATH 和 PYTHONHOME。py3compile 模块使用这两个变量查找不同的资源。PYTHONPATH 变量扩充了模块文件的默认搜索路径。PYTHONHOME 用于标准 Python 库。格式与 shell 的 PATH 相同。您需要按如下方式设置这些变量:

export PYTHONPATH='/path/to/pythondir:/path/to/pythondir/lib-dynload:/path/to/pythondir/site-packages'
export PYTHONHOME='/path/to/pythondir'

相关内容