Tôi đang sử dụng Ubuntu 16.04 lts. Tôi đã cài đặt
sudo update-alternatives --config python
7. Có hai phiên bản được cài đặt, sudo update-alternatives --config python
8 và sudo update-alternatives --config python
9. Bất cứ khi nào tôi sử dụng lệnh sudo update-alternatives --config python
7, theo mặc định, phải mất ____18. Tôi muốn sử dụng sudo update-alternatives --config python
9 với sudo update-alternatives --config python
7.update-alternatives: error: no alternatives for python3
4 cho thấy update-alternatives: error: no alternatives for python3
5Tôi đang cài đặt
update-alternatives: error: no alternatives for python3
6 hỗ trợ update-alternatives: error: no alternatives for python3
7. 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
8sudo update-alternatives --config python3
update-alternatives: error: no alternatives for python3
GAD3R
59,9k30 Huy hiệu vàng123 Huy hiệu bạc189 Huy hiệu Đồng30 gold badges123 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
update-alternatives: error: no alternatives for python3
9 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
59,9k30 Huy hiệu vàng123 Huy hiệu bạc189 Huy hiệu Đồng30 gold badges123 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:
- Bạn cần cập nhật
9 của mình, sau đó bạn sẽ có thể đặt phiên bản Python mặc định của mình.update-alternatives: error: no alternatives for python3
- Sau đó chạy :
2sudo 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
- Đặt Python3.6 làm mặc định.
- Done.
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
7
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
0root@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
Nhận đặc quyền người dùng gốc. Trên loại 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
1python2.7Nhập mật khẩu gốc của bạn.
root@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
Thực hiện lệnh này để chuyển sang Python 3.6:
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
2May 25, 2019 at 18:03
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
0IRSHADĐã trả lời ngày 2 tháng 2 năm 2019 lúc 9:375 silver badges3 bronze badges
6
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
4sudo 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
0, 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
1Kiể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
6sudo 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
7 [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
8]sudo update-alternatives --config python3
Login 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
8sudo update-alternatives --config python
0
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
0Đã trả lời ngày 8 tháng 11 năm 2018 lúc 11:441 gold badge32 silver badges59 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
1
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.1k1 Huy hiệu vàng32 Huy hiệu bạc59 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:
2sudo 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.
3sudo update-alternatives --config python
Chỉ cần thêm dòng này vào tệp ~/.bashrc:
sudo update-alternatives --config python
2, 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
3, nó sẽ được dịch thành sudo update-alternatives --config python
4.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
4CHỈNH SỬA :
sudo update-alternatives --config python
5Explanation:-
sudo update-alternatives --config python
6Như 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
5 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