1

首先,我不知道python。我认为这就是我遇到问题的原因。我正在尝试从源代码构建 compiz,但我坚持构建 simple-ccsm。simple-ccsm 的设置是使用 python 和 setup.py。安装时,它抱怨:

Package compiz was not found in the pkg-config search path.
Perhaps you should add the directory containing 'compiz.pc'
to the PKG_CONFIG_PATH environment variable
No package 'compiz' was found

现在,PKG_CONFIG_PATH 确实指向了正确的文件夹。更重要的是,pkg-config 还可以正确找到 compiz:

pkg-config --libs compiz

它确实安装了 simple-ccsm,但是当我运行它时,simple-ccsm 无法抱怨

ImportError: No module named compizconfig

我已经安装了 simple-ccsm 所需的所有依赖项(包括 compizconfig-python 绑定,它似乎通常会出现上述错误)所以,我想问一下 python 专家,我如何引导 python 查找正确的位置。我猜它以某种方式没有在正确的目录中查找。

4

1 回答 1

1

要将 Python 引导到正确的位置,您可能需要修改 PYTHONPATH:(正在编辑,因为链接已损坏)。

PYTHONPATH sets the search path for importing python modules:

PYTHONPATH Augment the default search path for module files. The format is 
the same as the shell’s PATH: one or more directory pathnames separated by 
os.pathsep (e.g. colons on Unix or semicolons on Windows). Non-existent 
directories are silently ignored.

In addition to normal directories, individual PYTHONPATH entries may refer 
to zipfiles containing pure Python modules (in either source or compiled 
form). Extension modules cannot be imported from zipfiles.

The default search path is installation dependent, but generally begins with 
prefix/lib/pythonversion (see PYTHONHOME above). It is always appended to 
PYTHONPATH.

An additional directory will be inserted in the search path in front of 
PYTHONPATH as described above under Interface options. The search path can 
be manipulated from within a Python program as the variable sys.path.

要设置变量,请在运行 python 脚本时指定它:

PYTHONPATH=/blah/whatever/ python somescript.py somecommand

或者将其导出到您的 Bash 环境:

export PYTHONPATH=/blah/whatever/

于 2013-06-05T20:10:48.177 回答