我需要PIL在我的python2.5.4-32bit上的Ubunto10.4-32bit(EDIT:64bit)机器上安装(python映像库).这个问题也与我猜测的任何其他源包有关(在我需要的那些中RPyC,psyco和numpy).
我下载了源代码,因为我找不到任何整洁的包来完成这项工作并做了一个sudo python2.5 setup.py install.
输出:
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Traceback (most recent call last):
File "setup.py", line 9, in <module>
import glob, os, re, struct, string, sys
File "/usr/lib/python2.5/struct.py", line 30, in <module>
from _struct import Struct, error
ImportError: No module named _struct
Run Code Online (Sandbox Code Playgroud)
但
echo $ PYTHONHOME
/ usr
那么,在文件中struct.py就行了from _struct import Struct, error
这是python源代码本身的一部分所以我真的很想知道python安装有什么问题,因为代码无法导入模块.
我通过以下方式安装了py2.5.4:
./configure --prefix=/usr
make altinstall
Run Code Online (Sandbox Code Playgroud)
(make altinstall因为我需要py26作为默认的python解释器)
编辑:这个问题可能是因错误地使用64位平台:)和32位python2.5而引起的.所以无论如何通过减少不必要的复杂性来解决问题 - 切换到32位机器并将应用程序移植到python 2.6.
首先尝试使用 Ubuntu 存储库。如果该包不存在,请使用easy_install. 如果全部失败,请将包直接下载到源文件夹。
Ubuntu(10.04 及更高版本)的大多数主流软件包都可以通过apt-get. 命名约定是python-NAME,例如python-imaging或python-scipy。
这是最好的方法,因为本机包管理器将处理任何依赖项和更新问题。
运行apt-cache search python | grep "^python-" | less以查看适用于您的系统的软件包列表(我的 10.04 机器中有超过 1,200 个软件包)。
对于不属于 Ubuntu 存储库的软件包,您可以使用 pythoneasy-install工具。首先,安装设置工具:
sudo apt-get install python-setuptools
Run Code Online (Sandbox Code Playgroud)
您可以使用以下命令安装任何 Python 包,例如colorworldeasy-install:
sudo easy_install colorworld
Run Code Online (Sandbox Code Playgroud)
这为您提供了一定程度的保护(例如,处理依赖关系),但更新通常是手动的,并且在新计算机中重新安装所有这些软件包确实很痛苦。
您始终可以将源代码下载到某个目录并将其添加到您的PYTHONPATH. 当您只需要评估软件包或应用一些快速而肮脏的解决方案时,这是最好的方法。