How to install Python using the “embeddable zip file”

前端 未结 1 1896
陌清茗
陌清茗 2021-01-18 13:15

I downloaded the Windows x86-64 embeddable zip file from https://www.python.org/downloads/release/python-365/.

(I cannot use the ex

1条回答
  •  野的像风
    2021-01-18 13:29

    There are 2 main steps (each with its own set of substeps) that need to be followed:

    1. Download and unpack the interpreter on your machine:

      1. Download the .zip file (e.g. [Python]: python-3.6.5-embed-amd64.zip) on your computer, in an empty dir (on my machine it's: "e:\Work\Dev\StackOverflow\q050818078\python36x64")
      2. Unzip the file (some (.pyd, .dll, .exe, .zip, ._pth) files will appear). At the end, you can delete the .zip file that you downloaded in previous step
    2. Configure PyCharm to use it:

      Notes:

      • In order for the images below to be a small as possible (from size and display PoV), I have reduced the sizes of all windows from their default values
      • Some PyCharm stuff is specific to my machine / environment, (obviously) that will be different in your case
      • The script that I used for testing, is a dummy one that just prints some paths (that's why I didn't add it as code, it's just in the 1st image)
      • I only illustrate the minimal required steps to get you going, so even if for some steps there are options to customize them, I'm not going to mention them
      • I am using PyCharm Community Edition 2017.3.3 (in other versions things could be slightly different)

      Steps:

      1. In PyCharm main window (considering your project is open), go to menu "File -> Settings...":

        You could also go to "File -> Default Settings...", check [JetBrains]: Project and IDE Settings for differences between them.

      2. In the "Settings" window, click "Project Interpreter -> Show All" (you might need to scroll down - if you have multiple interpreters configured)

      3. In the "Project Interpreters" window, click the "Add" button (green + on upper right side). Also, you might have to click an "Add Local..." control that appears when you click "Add"

      4. In the "Add Local Python Interpreter", make sure to:

        • Check "Exiting environment" radio button
        • Click the "..." ("Browse") button

      5. In the "Select Python Interpreter" window, go to the folder where you unzipped the file at #1.1., select python.exe and then click "OK"

      6. Click the "OK" button in all the windows opened at previous steps (in reversed order), until you're back to main window

    In order to test, on the code editor window, right click and from the popup menu choose "Run 'code'". Here's console output window content:

    E:\Work\Dev\StackOverflow\q050818078\python36x64\python.exe E:/Work/Dev/StackOverflow/q050818078/src/code.py
    Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 17:00:18) [MSC v.1900 64 bit (AMD64)] on win32
    
    E:\Work\Dev\StackOverflow\q050818078\python36x64\python.exe
    E:\Work\Dev\StackOverflow\q050818078\src\code.py
    
    Process finished with exit code 0
    

    As a final note, naming the test file code.py was "a bit" uninspired, as there is such a module in Python's standard library (in the meantime, I renamed it to code00.py), but I don't feel like doing all the screenshots (that contain it) again.

    0 讨论(0)
提交回复
热议问题