Cách để Khởi chạy tập tin Python bằng Windows Command Prompt

  1. Tiêu đề ảnh Use Windows Command Prompt to Run a Python File Step 12
    Tiêu đề ảnh Use Windows Command Prompt to Run a Python File Step 12

    {“smallUrl”:”https:\/\/www.wikihow.com\/images_en\/thumb\/8\/80\/Use-Windows-Command-Prompt-to-Run-a-Python-File-Step-12.jpg\/v4-460px-Use-Windows-Command-Prompt-to-Run-a-Python-File-Step-12.jpg”,”bigUrl”:”https:\/\/www.wikihow.com\/images\/thumb\/8\/80\/Use-Windows-Command-Prompt-to-Run-a-Python-File-Step-12.jpg\/v4-728px-Use-Windows-Command-Prompt-to-Run-a-Python-File-Step-12.jpg”,”smallWidth”:460,”smallHeight”:348,”bigWidth”:728,”bigHeight”:550,”licensing”:”<div class=\”mw-parser-output\”><\/div>”}

    1

    Hiển thị các thư mục ẩn. Vì một trong những thư mục chứa thư mục cài đặt Python rất có khả năng bị ẩn nên chúng ta cần bỏ ẩn chúng trước khi tiếp tục:

    • Mở File Explorer Tiêu đề ảnh File_Explorer_Icon.png

      {“smallUrl”:”https:\/\/www.wikihow.com\/images_en\/0\/04\/File_Explorer_Icon.png”,”bigUrl”:”https:\/\/www.wikihow.com\/images\/thumb\/0\/04\/File_Explorer_Icon.png\/30px-File_Explorer_Icon.png”,”smallWidth”:460,”smallHeight”:460,”bigWidth”:30,”bigHeight”:30,”licensing”:”<div class=\”mw-parser-output\”><\/div>”}

    • Nhấp vào thẻ View (Chế độ xem).
    • Tích vào ô “Hidden items” (Mục bị ẩn).

    Vì một trong những thư mục chứa thư mục cài đặt Python rất có khả năng bị ẩn nên chúng ta cần bỏ ẩn chúng trước khi tiếp tục:

  2. Tiêu đề ảnh Use Windows Command Prompt to Run a Python File Step 13
    Tiêu đề ảnh Use Windows Command Prompt to Run a Python File Step 13

    {“smallUrl”:”https:\/\/www.wikihow.com\/images_en\/thumb\/3\/39\/Use-Windows-Command-Prompt-to-Run-a-Python-File-Step-13.jpg\/v4-460px-Use-Windows-Command-Prompt-to-Run-a-Python-File-Step-13.jpg”,”bigUrl”:”https:\/\/www.wikihow.com\/images\/thumb\/3\/39\/Use-Windows-Command-Prompt-to-Run-a-Python-File-Step-13.jpg\/v4-728px-Use-Windows-Command-Prompt-to-Run-a-Python-File-Step-13.jpg”,”smallWidth”:460,”smallHeight”:348,”bigWidth”:728,”bigHeight”:551,”licensing”:”<div class=\”mw-parser-output\”><\/div>”}

    2

    Đi đến thư mục Python. Trong một số trường hợp, đường dẫn đến Python sẽ là “C:\Python27”; tuy nhiên, nếu bạn đã cài đặt phiên bản Python mới nhất bằng các thiết lập mặc định thì chương trình sẽ nằm trong thư mục ẩn. Bạn có thể sao chép đường dẫn tập tin thích hợp bằng cách:

    • Nhấp vào This PC nằm bên trái cửa sổ File Explorer.
    • Nhấp đúp vào ổ đĩa cứng nằm trong phần “Devices and drives”.
    • Cuộn xuống và nhấp đúp vào thư mục “Users”.
    • Nhấp đúp vào thư mục có tên người dùng của bạn.
    • Cuộn xuống và nhấp đúp “AppData”.
    • Nhấp đúp vào “Local”.
    • Cuộn xuống và nhấp đúp vào “Programs”.
    • Nhấp đúp vào thư mục “Python”.
    • Nhấp đúp vào thư mục Python cùng với số phiên bản thích hợp (ví dụ: “Python36”).

    Trong một số trường hợp, đường dẫn đến Python sẽ là “C:\Python27”; tuy nhiên, nếu bạn đã cài đặt phiên bản Python mới nhất bằng các thiết lập mặc định thì chương trình sẽ nằm trong thư mục ẩn. Bạn có thể sao chép đường dẫn tập tin thích hợp bằng cách:

  3. Tiêu đề ảnh Use Windows Command Prompt to Run a Python File Step 14
    Tiêu đề ảnh Use Windows Command Prompt to Run a Python File Step 14

    {“smallUrl”:”https:\/\/www.wikihow.com\/images_en\/thumb\/3\/34\/Use-Windows-Command-Prompt-to-Run-a-Python-File-Step-14.jpg\/v4-460px-Use-Windows-Command-Prompt-to-Run-a-Python-File-Step-14.jpg”,”bigUrl”:”https:\/\/www.wikihow.com\/images\/thumb\/3\/34\/Use-Windows-Command-Prompt-to-Run-a-Python-File-Step-14.jpg\/v4-728px-Use-Windows-Command-Prompt-to-Run-a-Python-File-Step-14.jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546,”licensing”:”<div class=\”mw-parser-output\”><\/div>”}

    3

    Sao chép đường dẫn đến thư mục Python. Nhấp vào thanh địa chỉ ở đầu cửa sổ File Explorer để tô sáng nội dung, sau đó nhấn

    Ctrl+C

    để sao chép địa chỉ vừa rồi.

  4. Tiêu đề ảnh Use Windows Command Prompt to Run a Python File Step 15
    Tiêu đề ảnh Use Windows Command Prompt to Run a Python File Step 15

    {“smallUrl”:”https:\/\/www.wikihow.com\/images_en\/thumb\/0\/0f\/Use-Windows-Command-Prompt-to-Run-a-Python-File-Step-15.jpg\/v4-460px-Use-Windows-Command-Prompt-to-Run-a-Python-File-Step-15.jpg”,”bigUrl”:”https:\/\/www.wikihow.com\/images\/thumb\/0\/0f\/Use-Windows-Command-Prompt-to-Run-a-Python-File-Step-15.jpg\/v4-728px-Use-Windows-Command-Prompt-to-Run-a-Python-File-Step-15.jpg”,”smallWidth”:460,”smallHeight”:344,”bigWidth”:728,”bigHeight”:545,”licensing”:”<div class=\”mw-parser-output\”><\/div>”}

    4

    Mở trình đơn Power User. Để tiến hành, bạn nhấp phải vào biểu tượng Start Tiêu đề ảnh Windowsstart.png

    {“smallUrl”:”https:\/\/www.wikihow.com\/images_en\/0\/07\/Windowsstart.png”,”bigUrl”:”https:\/\/www.wikihow.com\/images\/thumb\/0\/07\/Windowsstart.png\/30px-Windowsstart.png”,”smallWidth”:460,”smallHeight”:460,”bigWidth”:30,”bigHeight”:30,”licensing”:”<div class=\”mw-parser-output\”><\/div>”}

    • Bạn cũng có thể nhấn

      Win+X để mở trình đơn bật lên Power User.

    Để tiến hành, bạn nhấp phải vào biểu tượng. Một trình đơn sẽ bật lên.

  5. Tiêu đề ảnh Use Windows Command Prompt to Run a Python File Step 16
    Tiêu đề ảnh Use Windows Command Prompt to Run a Python File Step 16

    {“smallUrl”:”https:\/\/www.wikihow.com\/images_en\/thumb\/d\/d8\/Use-Windows-Command-Prompt-to-Run-a-Python-File-Step-16.jpg\/v4-460px-Use-Windows-Command-Prompt-to-Run-a-Python-File-Step-16.jpg”,”bigUrl”:”https:\/\/www.wikihow.com\/images\/thumb\/d\/d8\/Use-Windows-Command-Prompt-to-Run-a-Python-File-Step-16.jpg\/v4-728px-Use-Windows-Command-Prompt-to-Run-a-Python-File-Step-16.jpg”,”smallWidth”:460,”smallHeight”:344,”bigWidth”:728,”bigHeight”:545,”licensing”:”<div class=\”mw-parser-output\”><\/div>”}

    5

    Nhấp vào tùy chọn

    System

    (Hệ thống) nằm trong trình đơn bật lên. Một cửa sổ mới sẽ mở ra.

  6. Tiêu đề ảnh Use Windows Command Prompt to Run a Python File Step 17
    Tiêu đề ảnh Use Windows Command Prompt to Run a Python File Step 17

    {“smallUrl”:”https:\/\/www.wikihow.com\/images_en\/thumb\/c\/c8\/Use-Windows-Command-Prompt-to-Run-a-Python-File-Step-17.jpg\/v4-460px-Use-Windows-Command-Prompt-to-Run-a-Python-File-Step-17.jpg”,”bigUrl”:”https:\/\/www.wikihow.com\/images\/thumb\/c\/c8\/Use-Windows-Command-Prompt-to-Run-a-Python-File-Step-17.jpg\/v4-728px-Use-Windows-Command-Prompt-to-Run-a-Python-File-Step-17.jpg”,”smallWidth”:460,”smallHeight”:346,”bigWidth”:728,”bigHeight”:547,”licensing”:”<div class=\”mw-parser-output\”><\/div>”}

    6

    Nhấp vào

    System info

    (Thông tin hệ thống). Liên kết này nằm ở góc trên bên phải cửa sổ. Cửa sổ System Information sẽ mở ra.

  7. Tiêu đề ảnh Use Windows Command Prompt to Run a Python File Step 18
    Tiêu đề ảnh Use Windows Command Prompt to Run a Python File Step 18

    {“smallUrl”:”https:\/\/www.wikihow.com\/images_en\/thumb\/d\/d4\/Use-Windows-Command-Prompt-to-Run-a-Python-File-Step-18.jpg\/v4-460px-Use-Windows-Command-Prompt-to-Run-a-Python-File-Step-18.jpg”,”bigUrl”:”https:\/\/www.wikihow.com\/images\/thumb\/d\/d4\/Use-Windows-Command-Prompt-to-Run-a-Python-File-Step-18.jpg\/v4-728px-Use-Windows-Command-Prompt-to-Run-a-Python-File-Step-18.jpg”,”smallWidth”:460,”smallHeight”:344,”bigWidth”:728,”bigHeight”:544,”licensing”:”<div class=\”mw-parser-output\”><\/div>”}

    7

    Nhấp vào liên kết

    Advanced system settings

    (Cài đặt hệ thống nâng cao). Liên kết này nằm ở phía trên bên trái cửa sổ System Information. Lúc này, một cửa sổ khác sẽ bật lên.

  8. Tiêu đề ảnh Use Windows Command Prompt to Run a Python File Step 19
    Tiêu đề ảnh Use Windows Command Prompt to Run a Python File Step 19

    {“smallUrl”:”https:\/\/www.wikihow.com\/images_en\/thumb\/9\/9b\/Use-Windows-Command-Prompt-to-Run-a-Python-File-Step-19.jpg\/v4-460px-Use-Windows-Command-Prompt-to-Run-a-Python-File-Step-19.jpg”,”bigUrl”:”https:\/\/www.wikihow.com\/images\/thumb\/9\/9b\/Use-Windows-Command-Prompt-to-Run-a-Python-File-Step-19.jpg\/v4-728px-Use-Windows-Command-Prompt-to-Run-a-Python-File-Step-19.jpg”,”smallWidth”:460,”smallHeight”:343,”bigWidth”:728,”bigHeight”:543,”licensing”:”<div class=\”mw-parser-output\”><\/div>”}

    8

    Nhấp vào

    Environment Variables…

    (Biến môi trường). Tùy chọn này nằm ở góc dưới bên phải cửa sổ bật lên.

  9. Tiêu đề ảnh Use Windows Command Prompt to Run a Python File Step 20
    Tiêu đề ảnh Use Windows Command Prompt to Run a Python File Step 20

    {“smallUrl”:”https:\/\/www.wikihow.com\/images_en\/thumb\/4\/41\/Use-Windows-Command-Prompt-to-Run-a-Python-File-Step-20.jpg\/v4-460px-Use-Windows-Command-Prompt-to-Run-a-Python-File-Step-20.jpg”,”bigUrl”:”https:\/\/www.wikihow.com\/images\/thumb\/4\/41\/Use-Windows-Command-Prompt-to-Run-a-Python-File-Step-20.jpg\/v4-728px-Use-Windows-Command-Prompt-to-Run-a-Python-File-Step-20.jpg”,”smallWidth”:460,”smallHeight”:348,”bigWidth”:728,”bigHeight”:551,”licensing”:”<div class=\”mw-parser-output\”><\/div>”}

    9

    Tìm tiêu đề “Path” trong bảng “User variables” (Biến người dùng). Khung này nằm đầu cửa sổ Environment Variables.

    • Có thể bạn cần cuộn con trỏ chuột lên hoặc xuống trên khung “User variables” để tìm biến “Path”.

    Khung này nằm đầu cửa sổ Environment Variables.

  10. Tiêu đề ảnh Use Windows Command Prompt to Run a Python File Step 21
    Tiêu đề ảnh Use Windows Command Prompt to Run a Python File Step 21

    {“smallUrl”:”https:\/\/www.wikihow.com\/images_en\/thumb\/8\/85\/Use-Windows-Command-Prompt-to-Run-a-Python-File-Step-21.jpg\/v4-460px-Use-Windows-Command-Prompt-to-Run-a-Python-File-Step-21.jpg”,”bigUrl”:”https:\/\/www.wikihow.com\/images\/thumb\/8\/85\/Use-Windows-Command-Prompt-to-Run-a-Python-File-Step-21.jpg\/v4-728px-Use-Windows-Command-Prompt-to-Run-a-Python-File-Step-21.jpg”,”smallWidth”:460,”smallHeight”:341,”bigWidth”:728,”bigHeight”:540,”licensing”:”<div class=\”mw-parser-output\”><\/div>”}

    10

    Nhấp đúp vào tiêu đề “Path”. Một cửa sổ sẽ bật lên.

  11. Tiêu đề ảnh Use Windows Command Prompt to Run a Python File Step 22
    Tiêu đề ảnh Use Windows Command Prompt to Run a Python File Step 22

    {“smallUrl”:”https:\/\/www.wikihow.com\/images_en\/thumb\/4\/46\/Use-Windows-Command-Prompt-to-Run-a-Python-File-Step-22.jpg\/v4-460px-Use-Windows-Command-Prompt-to-Run-a-Python-File-Step-22.jpg”,”bigUrl”:”https:\/\/www.wikihow.com\/images\/thumb\/4\/46\/Use-Windows-Command-Prompt-to-Run-a-Python-File-Step-22.jpg\/v4-728px-Use-Windows-Command-Prompt-to-Run-a-Python-File-Step-22.jpg”,”smallWidth”:460,”smallHeight”:348,”bigWidth”:728,”bigHeight”:551,”licensing”:”<div class=\”mw-parser-output\”><\/div>”}

    11

    Nhấp vào tùy chọn

    New

    (Mới) nằm bên phải cửa sổ. Một trường văn bản sẽ hiện ra giữa cửa sổ.

  12. Tiêu đề ảnh Use Windows Command Prompt to Run a Python File Step 23
    Tiêu đề ảnh Use Windows Command Prompt to Run a Python File Step 23

    {“smallUrl”:”https:\/\/www.wikihow.com\/images_en\/thumb\/a\/aa\/Use-Windows-Command-Prompt-to-Run-a-Python-File-Step-23.jpg\/v4-460px-Use-Windows-Command-Prompt-to-Run-a-Python-File-Step-23.jpg”,”bigUrl”:”https:\/\/www.wikihow.com\/images\/thumb\/a\/aa\/Use-Windows-Command-Prompt-to-Run-a-Python-File-Step-23.jpg\/v4-728px-Use-Windows-Command-Prompt-to-Run-a-Python-File-Step-23.jpg”,”smallWidth”:460,”smallHeight”:347,”bigWidth”:728,”bigHeight”:549,”licensing”:”<div class=\”mw-parser-output\”><\/div>”}

    12

    Dán đường dẫn mà bạn đã sao chép trước đó. Nhấn

    Ctrl+V

    để dán nội dung vào. Đường dẫn mà bạn đã sao chép sẽ hiện ra trong trường văn bản nằm giữa cửa sổ.

  13. Tiêu đề ảnh Use Windows Command Prompt to Run a Python File Step 24
    Tiêu đề ảnh Use Windows Command Prompt to Run a Python File Step 24

    {“smallUrl”:”https:\/\/www.wikihow.com\/images_en\/thumb\/8\/82\/Use-Windows-Command-Prompt-to-Run-a-Python-File-Step-24-Version-2.jpg\/v4-460px-Use-Windows-Command-Prompt-to-Run-a-Python-File-Step-24-Version-2.jpg”,”bigUrl”:”https:\/\/www.wikihow.com\/images\/thumb\/8\/82\/Use-Windows-Command-Prompt-to-Run-a-Python-File-Step-24-Version-2.jpg\/v4-728px-Use-Windows-Command-Prompt-to-Run-a-Python-File-Step-24-Version-2.jpg”,”smallWidth”:460,”smallHeight”:344,”bigWidth”:728,”bigHeight”:544,”licensing”:”<div class=\”mw-parser-output\”><\/div>”}

    13

    Nhấp vào

    OK

    trên ba cửa sổ đang mở. Hệ thống sẽ lưu lại thay đổi, đồng thời đóng ba cửa sổ “Path”, “Environmental Variables” và “System Properties”.

    Quảng cáo