Python 3.6 无法安装到 Linux 下的非标准目录

标签 python linux python-3.x pip linux-from-scratch

我有一个完全隔离的 boostrapped 工具链 + 二进制文件设置(位于/home/tools 下),它能够构建我扔给它的所有东西。其中包括 Python 2.7.14,它使用简单的 --prefix 构建而没有问题。 唯一的异常(exception)是 Python 3.6.4。我不得不编辑 configure 和 setup.py 脚本来修补一些设置为标准/usr 目录的硬编码路径(ncursesw 的链接很明显)。它完全正确地编译和构建,除了在 pip 的“make install”安装过程中失败。安装脚本在/tmp 下创建了一个 pip-build-* 目录,失败的根源似乎是围绕着它。它出现在目录首次创建时,它是使用适当的权限掩码创建的。但是在失败之后,我可以看到它只是用户可写的(甚至不可读或可执行)。

d-w------- 4 myuser       eng      4096 Mar  1 00:56 pip-build-xh7onsny/

这是 strace 的第一个创建 pip-build-* 目录的部分。

    [pid 19771] lstat("/home/myuser/.cache/pip", {st_mode=S_IFDIR|0700, st_size=4096, ...}) = 0
    [pid 19771] geteuid()                   = 10345
    [pid 19771] access("/home/myuser/.cache/pip", W_OK) = 0
    [pid 19771] mkdir("/tmp/pip-build-xh7onsny", 0700) = 0
    [pid 19771] lstat("/tmp", {st_mode=S_IFDIR|S_ISVTX|0777, st_size=28672, ...}) = 0
    [pid 19771] lstat("/tmp/pip-build-xh7onsny", {st_mode=S_IFDIR|0700, st_size=4096, ...}) = 0
    [pid 19771] getcwd("/nfs/home/myuser/lfs/sources/Python-3.6.4"..., 1024) = 46

这里是 strace 的结尾,显示了出错的位置。

[pid 19771] munmap(0x2ac5506c0000, 4096) = 0
[pid 19771] stat("/nfs/home/myuser/lfs/sources/Python-3.6.4/Lib/shutil.py", {st_mode=S_IFREG|0644, st_size=40227, ...}) = 0
[pid 19771] open("/nfs/home/myuser/lfs/sources/Python-3.6.4/Lib/shutil.py", O_RDONLY|0x80000 /* O_??? */) = 4
[pid 19771] ioctl(4, FIOCLEX)           = 0
[pid 19771] fstat(4, {st_mode=S_IFREG|0644, st_size=40227, ...}) = 0
[pid 19771] ioctl(4, SNDCTL_TMR_TIMEBASE or TCGETS, 0x7fff38a58460) = -1 ENOTTY (Inappropriate ioctl for device)
[pid 19771] lseek(4, 0, SEEK_CUR)       = 0
[pid 19771] read(4, "\"\"\"Utility functions for copying"..., 32768) = 32768
[pid 19771] lseek(4, 0, SEEK_CUR)       = 32768
[pid 19771] read(4, "e, extract_dir=None, format=None"..., 8192) = 7459
[pid 19771] read(4, "", 8192)           = 0
[pid 19771] close(4)                    = 0
[pid 19771] ioctl(2, SNDCTL_TMR_TIMEBASE or TCGETS, 0x7fff38a59f40) = -1 EINVAL (Invalid argument)
[pid 19771] write(2, "Exception:\nTraceback (most recen"..., 1739Exception:
Traceback (most recent call last):
  File "/tmp/tmpojuc47gy/pip-9.0.1-py2.py3-none-any.whl/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/tmp/tmpojuc47gy/pip-9.0.1-py2.py3-none-any.whl/pip/commands/install.py", line 385, in run
    requirement_set.cleanup_files()
  File "/tmp/tmpojuc47gy/pip-9.0.1-py2.py3-none-any.whl/pip/utils/build.py", line 38, in __exit__
    self.cleanup()
  File "/tmp/tmpojuc47gy/pip-9.0.1-py2.py3-none-any.whl/pip/utils/build.py", line 42, in cleanup
    rmtree(self.name)
  File "/tmp/tmpojuc47gy/pip-9.0.1-py2.py3-none-any.whl/pip/_vendor/retrying.py", line 49, in wrapped_f
    return Retrying(*dargs, **dkw).call(f, *args, **kw)
  File "/tmp/tmpojuc47gy/pip-9.0.1-py2.py3-none-any.whl/pip/_vendor/retrying.py", line 212, in call
    raise attempt.get()
  File "/tmp/tmpojuc47gy/pip-9.0.1-py2.py3-none-any.whl/pip/_vendor/retrying.py", line 247, in get
    six.reraise(self.value[0], self.value[1], self.value[2])
  File "/tmp/tmpojuc47gy/pip-9.0.1-py2.py3-none-any.whl/pip/_vendor/six.py", line 686, in reraise
    raise value
  File "/tmp/tmpojuc47gy/pip-9.0.1-py2.py3-none-any.whl/pip/_vendor/retrying.py", line 200, in call
    attempt = Attempt(fn(*args, **kwargs), attempt_number, False)
  File "/tmp/tmpojuc47gy/pip-9.0.1-py2.py3-none-any.whl/pip/utils/__init__.py", line 102, in rmtree
    onerror=rmtree_errorhandler)
  File "/nfs/home/myuser/lfs/sources/Python-3.6.4/Lib/shutil.py", line 476, in rmtree
    onerror(os.lstat, path, sys.exc_info())
  File "/nfs/home/myuser/lfs/sources/Python-3.6.4/Lib/shutil.py", line 474, in rmtree
    fd = os.open(path, os.O_RDONLY)
PermissionError: [Errno 13] Permission denied: '/tmp/pip-build-xh7onsny'
) = 1739
[pid 19771] lstat("/tmp/tmpojuc47gy", {st_mode=S_IFDIR|0700, st_size=4096, ...}) = 0
[pid 19771] open("/tmp/tmpojuc47gy", O_RDONLY|0x80000 /* O_??? */) = 4
[pid 19771] ioctl(4, FIOCLEX)           = 0
[pid 19771] fstat(4, {st_mode=S_IFDIR|0700, st_size=4096, ...}) = 0
[pid 19771] fcntl(4, 0x406 /* F_??? */, 0) = -1 EINVAL (Invalid argument)
[pid 19771] close(4)                    = 0
[pid 19771] open("/nfs/home/myuser/lfs/sources/Python-3.6.4/Lib/runpy.py", O_RDONLY|0x80000 /* O_??? */) = 4
[pid 19771] ioctl(4, FIOCLEX)           = 0
[pid 19771] fstat(4, {st_mode=S_IFREG|0644, st_size=11959, ...}) = 0
[pid 19771] ioctl(4, SNDCTL_TMR_TIMEBASE or TCGETS, 0x7fff38a5b0d0) = -1 ENOTTY (Inappropriate ioctl for device)
[pid 19771] lseek(4, 0, SEEK_CUR)       = 0
[pid 19771] fcntl(4, 0x406 /* F_??? */, 0) = -1 EINVAL (Invalid argument)
[pid 19771] lseek(4, 0, SEEK_SET)       = 0
[pid 19771] lseek(4, 0, SEEK_CUR)       = 0
[pid 19771] read(4, "\"\"\"runpy.py - locating and runni"..., 8192) = 8192
[pid 19771] close(4)                    = 0
[pid 19771] open("/nfs/home/myuser/lfs/sources/Python-3.6.4/Lib/runpy.py", O_RDONLY|0x80000 /* O_??? */) = 4
[pid 19771] ioctl(4, FIOCLEX)           = 0
[pid 19771] fstat(4, {st_mode=S_IFREG|0644, st_size=11959, ...}) = 0
[pid 19771] ioctl(4, SNDCTL_TMR_TIMEBASE or TCGETS, 0x7fff38a5b0d0) = -1 ENOTTY (Inappropriate ioctl for device)
[pid 19771] lseek(4, 0, SEEK_CUR)       = 0
[pid 19771] fcntl(4, 0x406 /* F_??? */, 0) = -1 EINVAL (Invalid argument)
[pid 19771] lseek(4, 0, SEEK_SET)       = 0
[pid 19771] lseek(4, 0, SEEK_CUR)       = 0
[pid 19771] read(4, "\"\"\"runpy.py - locating and runni"..., 8192) = 8192
[pid 19771] close(4)                    = 0
[pid 19771] open("/nfs/home/myuser/lfs/sources/Python-3.6.4/Lib/ensurepip/__main__.py", O_RDONLY|0x80000 /* O_??? */) = 4
[pid 19771] ioctl(4, FIOCLEX)           = 0
[pid 19771] fstat(4, {st_mode=S_IFREG|0644, st_size=88, ...}) = 0
[pid 19771] ioctl(4, SNDCTL_TMR_TIMEBASE or TCGETS, 0x7fff38a5b0d0) = -1 ENOTTY (Inappropriate ioctl for device)
[pid 19771] lseek(4, 0, SEEK_CUR)       = 0
[pid 19771] fcntl(4, 0x406 /* F_??? */, 0) = -1 EINVAL (Invalid argument)
[pid 19771] lseek(4, 0, SEEK_SET)       = 0
[pid 19771] lseek(4, 0, SEEK_CUR)       = 0
[pid 19771] read(4, "import ensurepip\nimport sys\n\nif "..., 8192) = 88
[pid 19771] close(4)                    = 0
[pid 19771] open("/nfs/home/myuser/lfs/sources/Python-3.6.4/Lib/ensurepip/__init__.py", O_RDONLY|0x80000 /* O_??? */) = 4
[pid 19771] ioctl(4, FIOCLEX)           = 0
[pid 19771] fstat(4, {st_mode=S_IFREG|0644, st_size=6391, ...}) = 0
[pid 19771] ioctl(4, SNDCTL_TMR_TIMEBASE or TCGETS, 0x7fff38a5b0d0) = -1 ENOTTY (Inappropriate ioctl for device)
[pid 19771] lseek(4, 0, SEEK_CUR)       = 0
[pid 19771] fcntl(4, 0x406 /* F_??? */, 0) = -1 EINVAL (Invalid argument)
[pid 19771] lseek(4, 0, SEEK_SET)       = 0
[pid 19771] lseek(4, 0, SEEK_CUR)       = 0
[pid 19771] read(4, "import os\nimport os.path\nimport "..., 8192) = 6391
[pid 19771] close(4)                    = 0
[pid 19771] open("/nfs/home/myuser/lfs/sources/Python-3.6.4/Lib/ensurepip/__init__.py", O_RDONLY|0x80000 /* O_??? */) = 4
[pid 19771] ioctl(4, FIOCLEX)           = 0
[pid 19771] fstat(4, {st_mode=S_IFREG|0644, st_size=6391, ...}) = 0
[pid 19771] ioctl(4, SNDCTL_TMR_TIMEBASE or TCGETS, 0x7fff38a5b0d0) = -1 ENOTTY (Inappropriate ioctl for device)
[pid 19771] lseek(4, 0, SEEK_CUR)       = 0
[pid 19771] fcntl(4, 0x406 /* F_??? */, 0) = -1 EINVAL (Invalid argument)
[pid 19771] lseek(4, 0, SEEK_SET)       = 0
[pid 19771] lseek(4, 0, SEEK_CUR)       = 0
[pid 19771] read(4, "import os\nimport os.path\nimport "..., 8192) = 6391
[pid 19771] close(4)                    = 0
[pid 19771] open("/nfs/home/myuser/lfs/sources/Python-3.6.4/Lib/tempfile.py", O_RDONLY|0x80000 /* O_??? */) = 4
[pid 19771] ioctl(4, FIOCLEX)           = 0
[pid 19771] fstat(4, {st_mode=S_IFREG|0644, st_size=26635, ...}) = 0
[pid 19771] ioctl(4, SNDCTL_TMR_TIMEBASE or TCGETS, 0x7fff38a5b0d0) = -1 ENOTTY (Inappropriate ioctl for device)
[pid 19771] lseek(4, 0, SEEK_CUR)       = 0
[pid 19771] fcntl(4, 0x406 /* F_??? */, 0) = -1 EINVAL (Invalid argument)
[pid 19771] lseek(4, 0, SEEK_SET)       = 0
[pid 19771] lseek(4, 0, SEEK_CUR)       = 0
[pid 19771] read(4, "\"\"\"Temporary files.\n\nThis module"..., 8192) = 8192
[pid 19771] read(4, "       continue    # try again\n "..., 8192) = 8192
[pid 19771] read(4, "\n        \"\"\"\n        Close the t"..., 8192) = 8192
[pid 19771] read(4, "emporaryFileArgs['mode']:\n      "..., 8192) = 2059
[pid 19771] close(4)                    = 0
[pid 19771] open("/nfs/home/myuser/lfs/sources/Python-3.6.4/Lib/tempfile.py", O_RDONLY|0x80000 /* O_??? */) = 4
[pid 19771] ioctl(4, FIOCLEX)           = 0
[pid 19771] fstat(4, {st_mode=S_IFREG|0644, st_size=26635, ...}) = 0
[pid 19771] ioctl(4, SNDCTL_TMR_TIMEBASE or TCGETS, 0x7fff38a5b0d0) = -1 ENOTTY (Inappropriate ioctl for device)
[pid 19771] lseek(4, 0, SEEK_CUR)       = 0
[pid 19771] fcntl(4, 0x406 /* F_??? */, 0) = -1 EINVAL (Invalid argument)
[pid 19771] lseek(4, 0, SEEK_SET)       = 0
[pid 19771] lseek(4, 0, SEEK_CUR)       = 0
[pid 19771] read(4, "\"\"\"Temporary files.\n\nThis module"..., 8192) = 8192
[pid 19771] read(4, "       continue    # try again\n "..., 8192) = 8192
[pid 19771] read(4, "\n        \"\"\"\n        Close the t"..., 8192) = 8192
[pid 19771] read(4, "emporaryFileArgs['mode']:\n      "..., 8192) = 2059
[pid 19771] close(4)                    = 0
[pid 19771] open("/nfs/home/myuser/lfs/sources/Python-3.6.4/Lib/shutil.py", O_RDONLY|0x80000 /* O_??? */) = 4
[pid 19771] ioctl(4, FIOCLEX)           = 0
[pid 19771] fstat(4, {st_mode=S_IFREG|0644, st_size=40227, ...}) = 0
[pid 19771] ioctl(4, SNDCTL_TMR_TIMEBASE or TCGETS, 0x7fff38a5b0d0) = -1 ENOTTY (Inappropriate ioctl for device)
[pid 19771] lseek(4, 0, SEEK_CUR)       = 0
[pid 19771] fcntl(4, 0x406 /* F_??? */, 0) = -1 EINVAL (Invalid argument)
[pid 19771] lseek(4, 0, SEEK_SET)       = 0
[pid 19771] lseek(4, 0, SEEK_CUR)       = 0
[pid 19771] read(4, "\"\"\"Utility functions for copying"..., 8192) = 8192
[pid 19771] read(4, "    that are used to exclude fil"..., 8192) = 8192
[pid 19771] read(4, " = os.open(path, os.O_RDONLY)\n  "..., 8192) = 8192
[pid 19771] close(4)                    = 0
[pid 19771] open("/nfs/home/myuser/lfs/sources/Python-3.6.4/Lib/shutil.py", O_RDONLY|0x80000 /* O_??? */) = 4
[pid 19771] ioctl(4, FIOCLEX)           = 0
[pid 19771] fstat(4, {st_mode=S_IFREG|0644, st_size=40227, ...}) = 0
[pid 19771] ioctl(4, SNDCTL_TMR_TIMEBASE or TCGETS, 0x7fff38a5b0d0) = -1 ENOTTY (Inappropriate ioctl for device)
[pid 19771] lseek(4, 0, SEEK_CUR)       = 0
[pid 19771] fcntl(4, 0x406 /* F_??? */, 0) = -1 EINVAL (Invalid argument)
[pid 19771] lseek(4, 0, SEEK_SET)       = 0
[pid 19771] lseek(4, 0, SEEK_CUR)       = 0
[pid 19771] read(4, "\"\"\"Utility functions for copying"..., 8192) = 8192
[pid 19771] read(4, "    that are used to exclude fil"..., 8192) = 8192
[pid 19771] close(4)                    = 0
[pid 19771] open("/nfs/home/myuser/lfs/sources/Python-3.6.4/Lib/shutil.py", O_RDONLY|0x80000 /* O_??? */) = 4
[pid 19771] ioctl(4, FIOCLEX)           = 0
[pid 19771] fstat(4, {st_mode=S_IFREG|0644, st_size=40227, ...}) = 0
[pid 19771] ioctl(4, SNDCTL_TMR_TIMEBASE or TCGETS, 0x7fff38a5b0d0) = -1 ENOTTY (Inappropriate ioctl for device)
[pid 19771] lseek(4, 0, SEEK_CUR)       = 0
[pid 19771] fcntl(4, 0x406 /* F_??? */, 0) = -1 EINVAL (Invalid argument)
[pid 19771] lseek(4, 0, SEEK_SET)       = 0
[pid 19771] lseek(4, 0, SEEK_CUR)       = 0
[pid 19771] read(4, "\"\"\"Utility functions for copying"..., 8192) = 8192
[pid 19771] read(4, "    that are used to exclude fil"..., 8192) = 8192
[pid 19771] close(4)                    = 0
[pid 19771] write(2, "Traceback (most recent call last"..., 1425Traceback (most recent call last):
  File "/nfs/home/myuser/lfs/sources/Python-3.6.4/Lib/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/nfs/home/myuser/lfs/sources/Python-3.6.4/Lib/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/nfs/home/myuser/lfs/sources/Python-3.6.4/Lib/ensurepip/__main__.py", line 5, in <module>
    sys.exit(ensurepip._main())
  File "/nfs/home/myuser/lfs/sources/Python-3.6.4/Lib/ensurepip/__init__.py", line 204, in _main
    default_pip=args.default_pip,
  File "/nfs/home/myuser/lfs/sources/Python-3.6.4/Lib/ensurepip/__init__.py", line 117, in _bootstrap
    return _run_pip(args + [p[0] for p in _PROJECTS], additional_paths)
  File "/nfs/home/myuser/lfs/sources/Python-3.6.4/Lib/tempfile.py", line 807, in __exit__
    self.cleanup()
  File "/nfs/home/myuser/lfs/sources/Python-3.6.4/Lib/tempfile.py", line 811, in cleanup
    _shutil.rmtree(self.name)
  File "/nfs/home/myuser/lfs/sources/Python-3.6.4/Lib/shutil.py", line 480, in rmtree
    _rmtree_safe_fd(fd, path, onerror)
  File "/nfs/home/myuser/lfs/sources/Python-3.6.4/Lib/shutil.py", line 402, in _rmtree_safe_fd
    onerror(os.listdir, path, sys.exc_info())
  File "/nfs/home/myuser/lfs/sources/Python-3.6.4/Lib/shutil.py", line 399, in _rmtree_safe_fd
    names = os.listdir(topfd)
OSError: [Errno 22] Invalid argument: '/tmp/tmpojuc47gy'
) = 1425
[pid 19771] rt_sigaction(SIGINT, {SIG_DFL, [], SA_RESTORER, 0x2ac548950ab0}, {0x2ac5485f8ca0, [], SA_RESTORER, 0x2ac548950ab0}, 8) = 0
[pid 19771] munmap(0x2ac54c1df000, 1257472) = 0
[pid 19771] munmap(0x2ac54f203000, 262144) = 0
[pid 19771] sigaltstack(NULL, {ss_sp=0xc877ce0, ss_flags=0, ss_size=8192}) = 0
[pid 19771] sigaltstack({ss_sp=0, ss_flags=SS_DISABLE, ss_size=0}, NULL) = 0
[pid 19771] close(3)                    = 0
[pid 19771] futex(0x2ac54b6f78ac, FUTEX_WAKE_PRIVATE, 2147483647) = 0
[pid 19771] exit_group(1)               = ?
Process 19770 resumed
Process 19771 detached
[pid 19770] <... wait4 resumed> [{WIFEXITED(s) && WEXITSTATUS(s) == 1}], 0, NULL) = 19771
[pid 19770] rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
[pid 19770] --- SIGCHLD (Child exited) @ 0 (0) ---
[pid 19770] wait4(-1, 0x7fff47da9a04, WNOHANG, NULL) = -1 ECHILD (No child processes)
[pid 19770] rt_sigreturn(0xffffffffffffffff) = 0
[pid 19770] rt_sigaction(SIGINT, {SIG_DFL, [], SA_RESTORER, 0x3c31a30030}, {0x436f50, [], SA_RESTORER, 0x3c31a30030}, 8) = 0
[pid 19770] exit_group(1)               = ?
Process 16346 resumed
Process 19770 detached
[pid 16346] <... wait4 resumed> [{WIFEXITED(s) && WEXITSTATUS(s) == 1}], 0, NULL) = 19770
[pid 16346] --- SIGCHLD (Child exited) @ 0 (0) ---
[pid 16346] rt_sigreturn(0xffffffff)    = 19770
[pid 16346] write(2, "make: *** [Makefile:1099: instal"..., 43make: *** [Makefile:1099: install] Error 1
) = 43

这是“make install”过程的 stdout/stderr 输出。它来自另一次运行,因此目录略有不同。

Installing collected packages: setuptools, pip
Successfully installed pip-9.0.1 setuptools-28.8.0
Exception:
Traceback (most recent call last):
  File "/tmp/tmpkmstr4wc/pip-9.0.1-py2.py3-none-any.whl/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/tmp/tmpkmstr4wc/pip-9.0.1-py2.py3-none-any.whl/pip/commands/install.py", line 385, in run
    requirement_set.cleanup_files()
  File "/tmp/tmpkmstr4wc/pip-9.0.1-py2.py3-none-any.whl/pip/utils/build.py", line 38, in __exit__
    self.cleanup()
  File "/tmp/tmpkmstr4wc/pip-9.0.1-py2.py3-none-any.whl/pip/utils/build.py", line 42, in cleanup
    rmtree(self.name)
  File "/tmp/tmpkmstr4wc/pip-9.0.1-py2.py3-none-any.whl/pip/_vendor/retrying.py", line 49, in wrapped_f
    return Retrying(*dargs, **dkw).call(f, *args, **kw)
  File "/tmp/tmpkmstr4wc/pip-9.0.1-py2.py3-none-any.whl/pip/_vendor/retrying.py", line 212, in call
    raise attempt.get()
  File "/tmp/tmpkmstr4wc/pip-9.0.1-py2.py3-none-any.whl/pip/_vendor/retrying.py", line 247, in get
    six.reraise(self.value[0], self.value[1], self.value[2])
  File "/tmp/tmpkmstr4wc/pip-9.0.1-py2.py3-none-any.whl/pip/_vendor/six.py", line 686, in reraise
    raise value
  File "/tmp/tmpkmstr4wc/pip-9.0.1-py2.py3-none-any.whl/pip/_vendor/retrying.py", line 200, in call
    attempt = Attempt(fn(*args, **kwargs), attempt_number, False)
  File "/tmp/tmpkmstr4wc/pip-9.0.1-py2.py3-none-any.whl/pip/utils/__init__.py", line 102, in rmtree
    onerror=rmtree_errorhandler)
  File "/nfs/home/myuser/lfs/sources/Python-3.6.4/Lib/shutil.py", line 476, in rmtree
    onerror(os.lstat, path, sys.exc_info())
  File "/nfs/home/myuser/lfs/sources/Python-3.6.4/Lib/shutil.py", line 474, in rmtree
    fd = os.open(path, os.O_RDONLY)
PermissionError: [Errno 13] Permission denied: '/tmp/pip-build-in_asosn'
Traceback (most recent call last):
  File "/nfs/home/myuser/lfs/sources/Python-3.6.4/Lib/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/nfs/home/myuser/lfs/sources/Python-3.6.4/Lib/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/nfs/home/myuser/lfs/sources/Python-3.6.4/Lib/ensurepip/__main__.py", line 5, in <module>
    sys.exit(ensurepip._main())
  File "/nfs/home/myuser/lfs/sources/Python-3.6.4/Lib/ensurepip/__init__.py", line 204, in _main
    default_pip=args.default_pip,
  File "/nfs/home/myuser/lfs/sources/Python-3.6.4/Lib/ensurepip/__init__.py", line 117, in _bootstrap
    return _run_pip(args + [p[0] for p in _PROJECTS], additional_paths)
  File "/nfs/home/myuser/lfs/sources/Python-3.6.4/Lib/tempfile.py", line 807, in __exit__
    self.cleanup()
  File "/nfs/home/myuser/lfs/sources/Python-3.6.4/Lib/tempfile.py", line 811, in cleanup
    _shutil.rmtree(self.name)
  File "/nfs/home/myuser/lfs/sources/Python-3.6.4/Lib/shutil.py", line 480, in rmtree
    _rmtree_safe_fd(fd, path, onerror)
  File "/nfs/home/myuser/lfs/sources/Python-3.6.4/Lib/shutil.py", line 402, in _rmtree_safe_fd
    onerror(os.listdir, path, sys.exc_info())
  File "/nfs/home/myuser/lfs/sources/Python-3.6.4/Lib/shutil.py", line 399, in _rmtree_safe_fd
    names = os.listdir(topfd)
OSError: [Errno 22] Invalid argument: '/tmp/tmpkmstr4wc'
make: *** [Makefile:1109: altinstall] Error 1

值得注意的是,它实际上确实将 pip 二进制文件安装到我的 $prefix/bin 目录中,但安装后续包(如介子)以类似的方式失败,所以我假设 Python 3.6/pip 安装没有完全成功。好像也来自shutil.py。这是介子安装的strace。

write(2, "Traceback (most recent call last"..., 1805Traceback (most recent call last):
  File "/home/tools/lib/python3.6/shutil.py", line 399, in _rmtree_safe_fd
    names = os.listdir(topfd)
OSError: [Errno 22] Invalid argument: '/tmp/easy_install-0o0par1r'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "setup.py", line 98, in <module>
    complete DSL.''')
  File "/home/tools/lib/python3.6/distutils/core.py", line 148, in setup
    dist.run_commands()
  File "/home/tools/lib/python3.6/distutils/dist.py", line 955, in run_commands
    self.run_command(cmd)
  File "/home/tools/lib/python3.6/distutils/dist.py", line 974, in run_command
    cmd_obj.run()
  File "/home/tools/lib/python3.6/site-packages/setuptools/command/install.py", line 67, in run
    self.do_egg_install()
  File "/home/tools/lib/python3.6/site-packages/setuptools/command/install.py", line 117, in do_egg_install
    cmd.run()
  File "/home/tools/lib/python3.6/site-packages/setuptools/command/easy_install.py", line 410, in run
    self.easy_install(spec, not self.no_deps)
  File "/home/tools/lib/python3.6/site-packages/setuptools/command/easy_install.py", line 669, in easy_instal
l
    rmtree(tmpdir)
  File "/home/tools/lib/python3.6/site-packages/setuptools/command/easy_install.py", line 2227, in rmtree
    return shutil.rmtree(path, ignore_errors, onerror)
  File "/home/tools/lib/python3.6/shutil.py", line 480, in rmtree
    _rmtree_safe_fd(fd, path, onerror)
  File "/home/tools/lib/python3.6/shutil.py", line 402, in _rmtree_safe_fd
    onerror(os.listdir, path, sys.exc_info())
  File "/home/tools/lib/python3.6/site-packages/setuptools/command/easy_install.py", line 1677, in auto_chmod
    six.reraise(et, (ev[0], ev[1] + (" %s %s" % (func, arg))))
TypeError: 'OSError' object is not subscriptable
) = 1805
rt_sigaction(SIGINT, {SIG_DFL, [], SA_RESTORER, 0x2b2b4caa4ab0}, {0x2b2b4c74cca0, [], SA_RESTORER, 0x2b2b4caa
4ab0}, 8) = 0

我试过更改我自己的主目录下的/tmp 目录,但同样的错误发生了,而且对 pip-build-* 目录也有奇怪的只写权限。对于调试此问题和正确安装 Python 3.6.4 的任何帮助,我将不胜感激。谢谢!

背景:我已经设置了一个单独的、自举的工具链和二进制文件,它们与工作中的 Linux 服务器上的主机库完全隔离,遵循 Linux From Scratch 书中的大部分内容。它运行的是带有内核 2.6.18 的旧 Red Hat/CentOS 5 发行版,由于支持旧版 CAD 软件而无法更新。但是我现在有一个完整的工作环境,它有内核 (2.19)、GCC (7.3.0)、binutils (2.30) 等支持的最新 Glibc。我已经得到了正确构建的所有东西,甚至 X 库和 gtk 应用程序,都通过 rpath 直接引用我的库集。

这是我的配置 我需要设置 ac_cv_func_utimensat=noac_cv_func_futimens=no 因为我系统上的文件系统或内核可能没有' 支持纳秒时间戳。使用这些选项,并修补 configure/setup.py 文件以删除对/usr/lib/ncursesw 的引用并替换为我的/home/tools/lib 路径,一切都构建得很好。它是在 pip 的“make install”阶段失败的。

./configure --prefix=/home/tools \
  --enable-shared \
  --with-system-expat \
  --with-system-ffi \
  --with-ensurepip=install \
  ac_cv_func_utimensat=no \
  ac_cv_func_futimens=no

最佳答案

我已经安装了一长串 Python 版本,包括 3.6.4 到 ~/.local。 --prefix 从来没有任何问题。这是我用来(重新)编译和安装的脚本:

#! /bin/sh

prefix="$HOME"/.local

[ -f Makefile ] && make distclean
OPT="-DNDEBUG=1 -O3" LDFLAGS="-L$prefix/lib -Xlinker -R$prefix/lib" \
LD_LIBRARY_PATH="`pwd`:$prefix/lib" \
CC="${CC:-gcc}" CPPFLAGS="-DNDEBUG=1 $CPPFLAGS" CFLAGS="-O3 $CFLAGS" \
CXX="${CXX:-g++}" CXXFLAGS="-O3 $CXXFLAGS" LDFLAGS="-s $LDFLAGS" \
./configure --enable-shared --prefix="$prefix" &&
make &&
chmod -R a+rX build &&
exec make install

关于Python 3.6 无法安装到 Linux 下的非标准目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49074327/

相关文章:

python - 使用 PyCapture2 和 OpenCV 从 Point Grey 相机获取图像

python - 将 dataframe 转换为字典,但不将列名作为 python 中的键

python默认字典内存泄漏

c++ - 一段时间后创建线程失败

linux - 如何在 EC2 实例 (ubuntu) 上安装 RabbitMQ?

如果满足条件,则修改列表元素的 Pythonic 方法

python-3.x - 多处理显示 matplotlib 图

python - Pandas 数据帧索引的 itertools.permutations 使用了太多内存

python - Pytorch:在 dataloader.dataset 上使用 torch.utils.random_split() 后,数据中缺少批量大小

regex - 使用AWK 在满足条件时提取数据?