首页 > 解决方案 > 如何在 ubuntu 上更改 python-config 版本

问题描述

我已经在我的桌面上安装了 python3.6,里面已经有 python3.5 和 python2.7。我将 python 和 python3 的默认路径都更改为 python3.6,但似乎 python-config 仍在 python2.7 上,而 python3-config 仍在 python3.5 上。如何将默认的 python3-config 或 python-config 更改为 python3.6-config?谢谢您的帮助!

标签: python-config

解决方案


所以要详细说明我的评论,python通常附带一个这样的版本

ls -lisa /usr/local/bin/ | grep python
34138948    16 -r-xr-xr-x    2 root  wheel      5248 15 Apr. 03:12 python3.7
34138954     0 lrwxr-xr-x    1 root  wheel        17 15 Apr. 03:12 python3.7-config -> python3.7m-config
34138948    16 -r-xr-xr-x    2 root  wheel      5248 15 Apr. 03:12 python3.7m
34138949     8 -r-xr-xr-x    1 root  wheel      2936 15 Apr. 03:12 python3.7m-config
34127071    16 -r-xr-xr-x    1 root  wheel      5216 15 Apr. 10:59 python3.9
34127072     8 -r-xr-xr-x    1 root  wheel      3153 15 Apr. 10:59 python3.9-config

如您所见,有些名称已经是符号链接(带有 -> 的一次),因此如果您想以 python3-config 的形式访问 python3.9-config,则需要创建一个名称为 python3-config 的符号链接,指向二进制 python3。 9配置。

% sudo ln -s /usr/local/bin/python3.9-config /usr/local/bin/python3-config

所以现在应该给你

% which python3-config
/usr/local/bin/python3-config

现在再次查看目录显示符号链接

% ls -lisa /usr/local/bin | grep python3
34127092     0 lrwxr-xr-x    1 root  wheel        31 22 Juni 14:09 python3-config -> /usr/local/bin/python3.9-config
34138948    16 -r-xr-xr-x    2 root  wheel      5248 15 Apr. 03:12 python3.7
34138954     0 lrwxr-xr-x    1 root  wheel        17 15 Apr. 03:12 python3.7-config -> python3.7m-config
34138948    16 -r-xr-xr-x    2 root  wheel      5248 15 Apr. 03:12 python3.7m
34138949     8 -r-xr-xr-x    1 root  wheel      2936 15 Apr. 03:12 python3.7m-config
34127071    16 -r-xr-xr-x    1 root  wheel      5216 15 Apr. 10:59 python3.9
34127072     8 -r-xr-xr-x    1 root  wheel      3153 15 Apr. 10:59 python3.9-config

干杯

马库斯


推荐阅读