Hướng dẫn how do i make python 3.8 default? - làm cách nào để đặt python 3.8 làm mặc định?

Tôi đã tải xuống Python 3.8 trên Ubuntu 16.04 của tôi và nếu tôi viết

sudo update-alternatives --config python3
update-alternatives: error: no alternatives for python3
8 thì nó sẽ có mặt, nhưng khi tôi viết
sudo update-alternatives --config python3
update-alternatives: error: no alternatives for python3
9, tôi sẽ nhận được phiên bản Python cũ của mình là 3,5

wjandrea

25.1k8 Huy hiệu vàng53 Huy hiệu bạc73 Huy hiệu đồng8 gold badges53 silver badges73 bronze badges

Hỏi ngày 10 tháng 12 năm 2019 lúc 17:34Dec 10, 2019 at 17:34

0

Đặt bí danh:

alias python=python3.8

Sau đó, chạy

sudo update-alternatives --config python
0 trong bash sẽ chạy
sudo update-alternatives --config python3
update-alternatives: error: no alternatives for python3
8.

Để thực hiện thay đổi vĩnh viễn, hãy đặt dòng bí danh vào

sudo update-alternatives --config python
2. Nó sẽ có hiệu lực khi bạn mở bash.

Symlinks

Tại sao không liên kết
sudo update-alternatives --config python
3 đến
sudo update-alternatives --config python3
update-alternatives: error: no alternatives for python3
8?

Ubuntu tuân theo PEP 394, trong đó lệnh

sudo update-alternatives --config python
0 nên trỏ đến Python 2. Tuy nhiên, một bí danh hoạt động vì nó chỉ ảnh hưởng đến vỏ của bạn. Nó thậm chí không ảnh hưởng đến các tập lệnh bạn viết, nghĩa là nếu bạn muốn một tập lệnh chạy trong Python 3.8, bạn sẽ phải viết nó một cách rõ ràng trong shebang, ví dụ:
sudo update-alternatives --config python
6 thay vì
sudo update-alternatives --config python
7.

Tại sao ít nhất không phải là Symlink
sudo update-alternatives --config python
8 đến
sudo update-alternatives --config python3
update-alternatives: error: no alternatives for python3
8?

Một số điều sẽ bị phá vỡ vì có các thư viện dành riêng cho phiên bản. Ví dụ

update-alternatives: error: no alternatives for python3 
0 không có sẵn cho Python 3.8 trên Ubuntu 16.04, vì vậy Gnome Terminal sẽ không mở. Xem ví dụ Gnome Terminal sẽ không bắt đầu hỏi Ubuntu.

Thêm chi tiết

  • Làm thế nào để tạo ra lệnh chương trình 'Python' thực thi Python 3? Khi hỏi Ubuntu

Đã trả lời ngày 10 tháng 12 năm 2019 lúc 18:08Dec 10, 2019 at 18:08

wjandreawjandreawjandrea

25.1k8 Huy hiệu vàng53 Huy hiệu bạc73 Huy hiệu đồng8 gold badges53 silver badges73 bronze badges

4

Hỏi ngày 10 tháng 12 năm 2019 lúc 17:34

Đặt bí danh:

Sau đó, chạy

sudo update-alternatives --config python
0 trong bash sẽ chạy
sudo update-alternatives --config python3
update-alternatives: error: no alternatives for python3
8.

Để thực hiện thay đổi vĩnh viễn, hãy đặt dòng bí danh vào

sudo update-alternatives --config python
2. Nó sẽ có hiệu lực khi bạn mở bash.

SymlinksDec 10, 2019 at 17:42

3

Tại sao không liên kết

sudo update-alternatives --config python
3 đến
sudo update-alternatives --config python3
update-alternatives: error: no alternatives for python3
8?sudo apt install python-is-python3 - it effectively does a symlink, but it also keeps pace with future updates; so if your ubuntu distribution moves to say Python 3.9, the manual symlink will no longer work, but the package makes sure it is still valid.

Ubuntu tuân theo PEP 394, trong đó lệnh

sudo update-alternatives --config python
0 nên trỏ đến Python 2. Tuy nhiên, một bí danh hoạt động vì nó chỉ ảnh hưởng đến vỏ của bạn. Nó thậm chí không ảnh hưởng đến các tập lệnh bạn viết, nghĩa là nếu bạn muốn một tập lệnh chạy trong Python 3.8, bạn sẽ phải viết nó một cách rõ ràng trong shebang, ví dụ:
sudo update-alternatives --config python
6 thay vì
sudo update-alternatives --config python
7.

Tại sao ít nhất không phải là Symlink

sudo update-alternatives --config python
8 đến
sudo update-alternatives --config python3
update-alternatives: error: no alternatives for python3
8?Sep 5, 2021 at 15:07

Tôi đang sử dụng Ubuntu 16.04 lts. Tôi đã cài đặt

update-alternatives: error: no alternatives for python3 
4. Có hai phiên bản được cài đặt,
update-alternatives: error: no alternatives for python3 
5 và
update-alternatives: error: no alternatives for python3 
6. Bất cứ khi nào tôi sử dụng lệnh
update-alternatives: error: no alternatives for python3 
4, theo mặc định, phải mất ____35. Tôi muốn sử dụng
update-alternatives: error: no alternatives for python3 
6 với
update-alternatives: error: no alternatives for python3 
4.

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 cho thấy
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
2

Tôi đang cài đặ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
3 hỗ trợ
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
4. 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ì
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 --config python3
update-alternatives: error: no alternatives for python3

GAD3R

59,7K30 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

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 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,7K30 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

  1. Từ bình luận:
  2. Sẽ cho bạn thấy một lỗi:
  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
    
    6 của mình, sau đó bạn sẽ có thể đặt phiên bản Python mặc định của mình.
  4. Sau đó chạy :
    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
    
    9
  5. Đặt Python3.6 làm mặc định.
  6. 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 --config python3
update-alternatives: error: no alternatives for python3
9

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

Nhận đặc quyền người dùng gốc. Về 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
8python2.7

Nhậ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
9May 25, 2019 at 18:03

Kiểm tra phiên bản Python:

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

Đã trả lời ngày 2 tháng 2 năm 2019 lúc 9:375 silver badges3 bronze badges

6

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 --config python
    
    1
  3. Trong ví dụ trên nếu bạn thấy đầu ra của
    sudo update-alternatives --config python3
    update-alternatives: error: no alternatives for python3
    
    9, 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

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
8

Kiểm tra phiên bản Python:

sudo update-alternatives --config python
3

sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 1

Bí danh:

sudo update-alternatives --config python
4 [Thêm điều này vào
sudo update-alternatives --config python
5]

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

Login hoặc Nguồn

sudo update-alternatives --config python
5

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

Kiểm tra lại phiên bản Python:

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

Đã 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 python3
update-alternatives: error: no alternatives for python3
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.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 tùy chọn cấu hình

sudo update-alternatives  --set python /usr/bin/python3.6
2 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ủ:

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

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:

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

Đã trả lời ngày 13 tháng 12 năm 2017 lúc 9:27Dec 13, 2017 at 9:27

3

Cập nhật-các giao dịch viên là để thay đổi hệ thống Symlink thành các liên kết symlink do người dùng xác định/quản trị viên. Nếu bạn có nhiều phiên bản python3 được cài đặt trong hệ thống của mình và muốn kiểm soát phiên bản python3 nào để gọi khi python3 được gọi. Làm như sau

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

Chạy lệnh bên dưới nếu bạn muốn thay đổi ưu tiên trong tương lai.

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

Explanation:-

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

Bạn có thể tiếp tục thay đổi name_of_config thành python4, nhưng sau đó bạn phải gọi các đồng nghiệp cập nhật-config với python4 để cấu hình lại.

Sử dụng phương pháp này, bạn có thể kiểm soát phiên bản Python và phiên bản Python3 một cách riêng biệt.

Đã trả lời ngày 13 tháng 3 năm 2019 lúc 20:02Mar 13, 2019 at 20:02

1

Bạn có thể thay đổi liên kết Simbolic bằng

sudo update-alternatives  --set python /usr/bin/python3.6
3 bên trong
sudo update-alternatives  --set python /usr/bin/python3.6
4. Với điều này khi bạn gọi
update-alternatives: error: no alternatives for python3 
4, nó sẽ thực thi
sudo update-alternatives  --set python /usr/bin/python3.6
6

Đã trả lời ngày 21 tháng 5 năm 2019 lúc 10:42May 21, 2019 at 10:42

Làm cách nào để đặt Python 3 thành mặc định?

Các bước để đặt Python3 làm mặc định trên Ubuntu ?..
Kiểm tra phiên bản Python trên thiết bị đầu cuối -Python --Version ..
Nhận đặc quyền người dùng gốc.Về loại thiết bị đầu cuối - sudo su ..
Viết ra mật khẩu người dùng gốc ..
Thực hiện lệnh này để chuyển sang Python 3.6.....
Kiểm tra phiên bản Python -Python --Version ..
Tất cả đã được làm xong!.

Làm cách nào để thay đổi Python thành 3,8 trên Mac?

Mở thiết bị đầu cuối [bash hoặc zsh] bất cứ vỏ nào bạn đang sử dụng.Cài đặt Python-3 bằng Homebrew [//brew.sh].Nhìn nơi nó được cài đặt.Thay đổi Python Symlink mặc định thành phiên bản bạn muốn sử dụng từ trên.

Chủ Đề