【问题标题】:Unable to install python无法安装python
【发布时间】:2017-10-28 13:08:28
【问题描述】:

我尝试通过下载源代码在 OpenSuSE Linux 上手动安装 Python,然后运行:

configure --prefix=/path/to/my/dir/installed/python

make && make install

(我必须这样做,因为我使用的是我机构提供的服务器,而我没有 root 访问权限)

这给了我以下警告:

make: warning: Clock skew detected. Your build may be incomplete.

我不确定该警告是否与我将来遇到的错误有关。 (编辑:这个警告现在消失了)

我检查了安装日志,我意识到它给了我以下错误:

gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/path/to/my/dir/installed/python/include -I. -IInclude -I./Include -I/usr/local/include -I/path/to/my/dir/setup/Python-2.7.11/Include -I/path/to/my/dir/setup/Python-2.7.11 -c /path/to/my/dir/setup/Python-2.7.11/Modules/_curses_panel.c -o build/temp.linux-x86_64-2.7/path/to/my/dir/setup/Python-2.7.11/Modules/_curses_panel.o
/path/to/my/dir/setup/Python-2.7.11/Modules/_curses_panel.c:17:19: fatal error: panel.h: No such file or directory
 #include <panel.h>
                   ^
compilation terminated.

Python build finished, but the necessary bits to build these modules were not found:
bsddb185           dl                 imageop         
sunaudiodev                                           
To find the necessary bits, look in setup.py in detect_modules() for the module's name.

现在我通过

运行 python
/path/to/my/dir/installed/python/bin/python

它给了我以下错误:

Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Python 2.7.13 (default, May 26 2017, 18:16:53) 
[GCC 4.8.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Traceback (most recent call last):
  File "/etc/pythonstart", line 7, in <module>
    import readline
ImportError: No module named readline

我尝试使用How can I troubleshoot Python "Could not find platform independent libraries <prefix>" 以及一些类似的链接来修复此错误,并将我的环境变量设置为:

export PYTHONPATH='/path/to/my/dir/installed/python/lib/:/path/to/my/dir/installed/python/lib/lib-dynload:/path/to/my/dir/installed/python/lib/python2.7/site-packages'
export PYTHONHOME='/path/to/my/dir/installed/python/lib

现在如果我运行 python,它会给我这个错误:

ImportError: No module named site

我在 Stackoverflow 上搜索后者的解决方案,但他们只是告诉我回去取消设置 $PYTHONHOME$PYTHONPATH ...

我也尝试过将两条路径重置到其他位置,但都不起作用。

供您参考,如果我取消设置路径,然后运行python,它仍然会输出之前的“找不到依赖库”错误,如果我尝试找到它提供的路径:

>>>import sys
>>>sys.path
['', '/path/to/my/dir/installed/python/lib/python27.zip',
'/path/to/my/dir/installed/python/lib/python2.7',
'/path/to/my/dir/installed/python/lib/python2.7/plat-linux2', 
'/path/to/my/dir/installed/python/lib/python2.7/lib-tk', 
'/path/to/my/dir/installed/python/lib/python2.7/lib-old', 
'/path/to/my/dir/installed/python/lib/lib-dynload',
'/path/to/my/dir/installed/python/lib/python2.7/site-packages']

【问题讨论】:

  • 运行 make distclean 或删除并替换源。在运行configure 之前运行find . -type f | xargs touch 然后运行make &amp;&amp; make install
  • @Deathgrip 时钟倾斜错误消失了,但我仍然有 ImportError...
  • 服务器不是已经安装了Python吗?如果没有,也许您可​​以要求管理员安装它?大多数服务器已经有了它。或者也许这会有所帮助? software.opensuse.org/package/python3
  • @JohnZwinck 是的,但是我需要一些额外的库,安装需要root,因为我需要一个新版本的numpy,并且系统管理员已经安装了一个旧版本的numpy,它是非常不得不让他们都在那里......
  • 其实,没关系,我只是意识到 Python3 的 numpy 是旧版本,但 Python2 的那个很好,我忘记将 pip 覆盖为 pip2,它只需要从源代码安装 easy-install。只要系统管理员为我们安装的其他库没有过期,问题就暂时得到解决。

标签: linux python-2.7 installation python-install


【解决方案1】:

您可能已经找到了答案。但是对于将来需要帮助的任何人,我找到了一个对自己有用的答案。打开命令提示符/终端,输入以下命令。

$ sudo apt-get update
$ sudo apt-get install python3.6

如果你做对了,python 3.6 应该会成功安装。

【讨论】:

  • 我完全不记得我是如何解决它的,哈哈,但这不是解决方案,当时我没有 sudo 授权
猜你喜欢
  • 2021-11-10
  • 2016-02-25
  • 2015-04-10
  • 2012-10-11
  • 2011-06-14
  • 2021-01-23
  • 2021-02-25
  • 2021-01-24
相关资源
最近更新 更多