Hướng dẫn how do i change python to 3.6 in ubuntu? - Làm cách nào để thay đổi python thành 3.6 trong Ubuntu?

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 
6

Tô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 
9

sudo update-alternatives --config python3
update-alternatives: error: no alternatives for python3

Hướng dẫn how do i change python to 3.6 in ubuntu? - Làm cách nào để thay đổi python thành 3.6 trong Ubuntu?

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

  1. Từ bình luận:

  2. Sẽ cho bạn thấy một lỗi:

    sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 1
    
  3. 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.

  4. Done.

Hướng dẫn how do i change python to 3.6 in ubuntu? - Làm cách nào để thay đổi python thành 3.6 trong Ubuntu?

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
1

root@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
1

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

Kusalananda ♦May 25, 2019 at 18:03

Hướng dẫn how do i change python to 3.6 in ubuntu? - Làm cách nào để thay đổi python thành 3.6 trong Ubuntu?

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

  1. 7835 Huy hiệu bạc2 Huy hiệu Đồng
  2. 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
    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
    
    3
  3. Trong ví dụ trên nếu bạn thấy đầu ra của
    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, bạn sẽ nhận được Python2.7
  4. 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

Hướng dẫn how do i change python to 3.6 in ubuntu? - Làm cách nào để thay đổi python thành 3.6 trong Ubuntu?

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
0

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
5

sudo 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
0

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
7

sudo update-alternatives --config python
1

Hướng dẫn how do i change python to 3.6 in ubuntu? - Làm cách nào để thay đổi python thành 3.6 trong Ubuntu?

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

Hướng dẫn how do i change python to 3.6 in ubuntu? - Làm cách nào để thay đổi python thành 3.6 trong Ubuntu?

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:

sudo update-alternatives --config python
3

Đã 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.

sudo update-alternatives --config python
4

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:27

3

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
5

CHỈNH SỬA :

sudo update-alternatives --config python
6

Explanation:-

sudo update-alternatives --config python
7

Như 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