Tôi đang sử dụng Ubuntu 16.04 lts. Tôi đã cài đặt
sudo update-alternatives --config python
8. Có hai phiên bản được cài đặt, sudo update-alternatives --config python
9 và update-alternatives: error: no alternatives for python3
0. Bất cứ khi nào tôi sử dụng lệnh sudo update-alternatives --config python
8, theo mặc định, phải mất ____19. Tôi muốn sử dụng update-alternatives: error: no alternatives for python3
0 với sudo update-alternatives --config python
8.update-alternatives: error: no alternatives for python3
5 cho thấy update-alternatives: error: no alternatives for python3
6Tôi đang cài đặt
update-alternatives: error: no alternatives for python3
7 hỗ trợ update-alternatives: error: no alternatives for python3
8. Vì vậy, bất cứ khi nào, tôi nhập Ansible vào thiết bị đầu cuối, nó gây ra lỗi vì update-alternatives: error: no alternatives for python3
9sudo update-alternatives --config python3
update-alternatives: error: no alternatives for python3
GAD3R
60K30 Huy hiệu vàng125 Huy hiệu bạc189 Huy hiệu Đồng30 gold badges125 silver badges189 bronze badges
Hỏi ngày 13 tháng 12 năm 2017 lúc 9:13Dec 13, 2017 at 9:13
8
Từ bình luận:
sudo update-alternatives --config python
Sẽ cho bạn thấy một lỗi:
update-alternatives: error: no alternatives for python3
Bạn cần cập nhật
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.4 1
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.6 2
0 của mình, sau đó bạn sẽ có thể đặt phiên bản Python mặc định của mình.sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.4 1
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.6 2
Sau đó chạy :
sudo update-alternatives --config python
Đặt Python3.6 làm mặc định.
Hoặc sử dụng lệnh sau để đặt Python3.6 làm mặc định:
sudo update-alternatives --set python /usr/bin/python3.6
Đã trả lời ngày 14 tháng 12 năm 2017 lúc 12:11Dec 14, 2017 at 12:11
GAD3RGAD3RGAD3R
60K30 Huy hiệu vàng125 Huy hiệu bạc189 Huy hiệu Đồng30 gold badges125 silver badges189 bronze badges
14
Hỏi ngày 13 tháng 12 năm 2017 lúc 9:13
Từ bình luận:
Sẽ cho bạn thấy một lỗi:
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 1
Bạn cần cập nhật
0 của mình, sau đó bạn sẽ có thể đặt phiên bản Python mặc định của mình.sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.4 1 sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.6 2
Done.
Sau đó chạy :♦
Đặt Python3.6 làm mặc định.33 gold badges586 silver badges886 bronze badges
Hoặc sử dụng lệnh sau để đặt Python3.6 làm mặc định:Feb 2, 2019 at 9:37
Đã trả lời ngày 14 tháng 12 năm 2017 lúc 12:11Vineet Jain
Bạn có thể đạt được điều này bằng cách áp dụng dưới đây các bước đơn giản -5 silver badges2 bronze badges
2
Kiểm tra phiên bản Python trên thiết bị đầu cuối:
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.4 1
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.6 2
1root@irshad:/usr/bin# ls -lrth python*
lrwxrwxrwx 1 root root 9 Apr 16 2018 python -> python2.7
-rwxr-xr-x 1 root root 3.6M Nov 12 2018 python2.7
-rwxr-xr-x 2 root root 4.4M May 7 14:58 python3.6
Thực hiện lệnh này để chuyển sang Python 3.6:python2.7
Kiểm tra phiên bản Python:
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.4 1
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.6 2
1root@irshad:/usr/bin# unlink python
root@irshad:/usr/bin# ln -s /usr/bin/python3.6 python
root@irshad:/usr/bin# python --version
Python 3.6.8
Kusalananda ♦May 25, 2019 at 18:03
300K33 Huy hiệu vàng586 Huy hiệu bạc886 Huy hiệu ĐồngIRSHAD
Đã trả lời ngày 2 tháng 2 năm 2019 lúc 9:375 silver badges3 bronze badges
3
Vineet Jainvineet Jain
- 7835 Huy hiệu bạc2 Huy hiệu Đồng
- Nếu bạn có nhiều phiên bản Python trong hệ thống của mình. Bạn chỉ cần cập nhật liên kết tượng trưng của Python bên trong
3sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.4 1 sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.6 2
- Trong ví dụ trên nếu bạn thấy đầu ra của
1, bạn sẽ nhận được Python2.7sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.4 1 sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.6 2
- Bây giờ hãy cập nhật python symlink bằng lệnh bên dưới-
Đã trả lời ngày 25 tháng 5 năm 2019 lúc 18:03Nov 8, 2018 at 11:44
IrshadirshadNewt
5095 Huy hiệu bạc3 Huy hiệu Đồng2 silver badges4 bronze badges
3
Sử dụng các lệnh này có thể giúp bạn:
sudo update-alternatives --config python
0Kiểm tra phiên bản Python:
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.4 1
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.6 2
5sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 1
Bí danh:
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.4 1
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.6 2
6 [Thêm điều này vào sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.4 1
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.6 2
7]sudo update-alternatives --config python
0Login hoặc nguồn
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.4 1
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.6 2
7sudo update-alternatives --config python
1
Kiểm tra lại phiên bản Python:
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.4 1
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.6 2
1Đã trả lời ngày 8 tháng 11 năm 2018 lúc 11:441 gold badge32 silver badges61 bronze badges
NewtnewtMay 21, 2019 at 10:29
3692 Huy hiệu bạc4 Huy hiệu đồngmmblack
Trước tiên, hãy kiểm tra xem bạn có thư mục Python3.6 không?1 silver badge4 bronze badges
3
Nếu bạn có thư mục "Python3.6", bạn tốt để đi. Bây giờ cập nhật-thay thế
sudo update-alternatives --config python
2
Sau đó cập nhật cấu hình mới cho Python3Dec 4, 2018 at 11:13
1
Cuối cùng, hãy kiểm tra phiên bản Python3 mặc định:
Stewart
10,3K1 Huy hiệu vàng32 Huy hiệu bạc61 Huy hiệu đồng
Đã trả lời ngày 21 tháng 5 năm 2019 lúc 10:29
mmblackmmblack
Huy hiệu đồng 1471 Bạc4 Huy hiệu Đồng
Tạo Symlink cho/usr/bin/python3. Trong Linuxmint của tôi:
3sudo update-alternatives --config python
Đã trả lời ngày 4 tháng 12 năm 2018 lúc 11:13
Một câu trả lời dễ dàng sẽ là thêm một bí danh cho Python3.6.
4sudo update-alternatives --config python
Chỉ cần thêm dòng này vào tệp ~/.bashrc:
sudo update-alternatives --config python
1, sau đó đóng thiết bị đầu cuối của bạn và mở một cái mới. Bây giờ khi bạn nhập sudo update-alternatives --config python
2, nó sẽ được dịch thành sudo update-alternatives --config python
3.Dec 13,
2017 at 9:273
Giải pháp này khắc phục vấn đề của bạn mà không cần phải điều chỉnh hệ thống của bạn quá nhiều.
sudo update-alternatives --config python
5CHỈNH SỬA :
sudo update-alternatives --config python
6Explanation:-
sudo update-alternatives --config python
7Như Mikael Kjær đã chỉ ra, đây là một cấu hình sai về ansible với hệ thống của bạn.
Như đã thấy ở đây:
Đặt tùy chọn cấu hình
sudo update-alternatives --config python
4 thành/usr/bin/python3. Tùy chọn cấu hình ansible_python_interpreter thường được đặt trên mỗi máy chủ làm biến hàng tồn kho được liên kết với máy chủ hoặc nhóm máy chủ:Mar 13, 2019 at 20:02
1
Như đã thấy ở đây về tệp cấu hình:
Các thay đổi có thể được thực hiện và sử dụng trong tệp cấu hình sẽ được xử lý theo thứ tự sau:May 21, 2019 at 10:42