在Python 2.6.4中安装SUDS

2 投票
3 回答
22322 浏览
提问于 2025-04-15 17:58

我在安装 SUDS 这个库的时候遇到了很大的麻烦,使用的是 Python 2.6.4。我尝试安装设置文件,但系统提示找不到 Python 的位置。这是因为我已经改变了 Python 的安装位置。我也试过用 easy_install,但一直没有成功。有没有人知道简单的方法或者能提供清晰的安装说明链接。

我输入的命令是:

python setup.py install

我得到的结果是:

running install
error: cannot create or remove files in install directory

The following error occurred while trying to add or remove files in the
installation directory:

    [Errno 13] Permission denied: '/usr/local/lib/python2.6/site-packages/test-easy-install-9203.write-test'

The installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:

    /usr/local/lib/python2.6/site-packages/

Perhaps your account does not have write access to this directory?  If the
installation directory is a system-owned directory, you may need to sign in
as the administrator or "root" account.  If you do not have administrative
access to this machine, you may wish to choose a different installation
directory, preferably one that is listed in your PYTHONPATH environment
variable.

For information on other options, you may wish to consult the
documentation at:

  http://peak.telecommunity.com/EasyInstall.html

如果我需要更改 Python 的路径,具体该怎么做呢?

我尝试过一个网站上说的方法,首先是在 Python 的 site-packages 目录下创建一个 altinstall.pth 文件,里面包含以下内容:

import os, site; site.addsitedir(os.path.expanduser('~/lib/python2.3'))

然后它说要在 distutils 目录下修改 distutils.cfg 文件,内容是:

[install]
install_lib = ~/lib/python2.3
# This next line is optional but often quite useful; it directs EasyInstall
# and the distutils to install scripts in the user's "bin" directory.  For
# Mac OS X framework Python builds, you should use /usr/local/bin instead,
# because neither ~/bin nor the default script installation location are on
# the system PATH.
#
install_scripts = ~/bin

3 个回答

0

为了给你一个准确的回答,我需要更多关于你操作系统的信息。从你的问题来看,你可能改变了Python的路径。通常情况下,你的操作系统会自带一个兼容的Python版本。例如,CentOS 5.x自带的是Python 2.4,但你可以通过yum install来安装Python 2.6。安装完成后,你可以用python26这个命令来运行Python 2.6。

在安装软件和包的时候,我建议你尽量使用包管理工具,因为它们可以帮助你处理依赖关系,比如yum。Yum还可以帮助你更新软件包,而不需要手动去更新。其次,你可以通过pipeasy install来安装软件。针对这个问题,你可以试试easy_install https://fedorahosted.org/releases/s/u/suds/python-suds-0.4.tar.gz(需要setuptools),如果实在不行,你可以尝试手动安装。如果我发现自己在做手动安装,我会觉得自己哪里做错了 :) 其他人也提供了关于如何手动安装的详细信息。

祝你好运。

1

我在安装suds和python-ntlm的时候也遇到了类似的消息。我们的网站有一个单独的安装区域,这样我们可以维护多个版本,所以我第一步的安装是

python setup.py install --prefix=/install/suds/suds-0.4

然后我也收到了关于installplace的相同消息。要解决这个问题:

确保这些目录存在,可以用

mkdir -p  /install/suds/suds-0.4/lib/python2.6/site-packages/

(这让我有点惊讶,我以为安装程序会自动创建这些目录。)

确保你在整个目录树中都有写权限,可以用

chmod -R 775 /install/suds/suds-0.4/lib/python2.6/site-packages/

但这两步都没有消除那个消息!

最后一步是把安装区域放进PYTHONPATH,然后运行setup.py

export PYTHONPATH=/install/suds/suds-0.4/lib/python2.6/site-packages:$PYTHONPATH
python setup.py install --prefix=/opt/sw/fw/qce/suds/suds-0.4

最后再用chmod命令确保新安装的文件可以被读取,以防umask设置得比较严格:

 chmod 755 /install/suds/suds-0.4/lib/python2.6/site-packages/*

完成这些后,我可以启动python并导入suds。关键步骤就是把suds的site-packages目录放进PYTHONPATH。

我知道这些帮助可能来得太晚,无法帮助最初提问的人,但我希望能帮助到其他在Stack Overflow上有同样问题的人。就像我当时一样。

3

你有没有试过把PYTHONPATH设置成Python的安装位置?这样的话,它就知道该往哪里安装了。

你现在是用python setup.py install来运行的。如果你在用某个Linux系统,并且有管理员权限,可以试试sudo python setup.py install

撰写回答