如何使用“可嵌入的 zip 文件"安装 Python [英] How to install Python using the "embeddable zip file"

查看:48
本文介绍了如何使用“可嵌入的 zip 文件"安装 Python的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从

您也可以转到文件 ->默认设置...",检查

  • 项目口译员"中窗口,单击添加"按钮(右上角的绿色 +).此外,您可能需要单击添加本地..."按钮.单击添加"

    时出现的控件

  • 添加本地 Python 解释器"中,确保:

    • 检查退出环境";单选按钮
    • 点击...";(浏览")按钮

  • 选择 Python 解释器"中窗口,转到您在 #1.1. 中解压文件的文件夹,选择 python.exe,然后单击确定""

  • 点击确定";在前面步骤打开的所有窗口中的按钮(以相反的顺序),直到你回到主窗口

  • 为了测试,在代码编辑器窗口中,右键单击并从弹出菜单中选择运行‘代码’".这是控制台输出窗口的内容:

    <块引用>

    E:\Work\Dev\StackOverflow\q050818078\python36x64\python.exe E:/Work/Dev/StackOverflow/q050818078/src/code.pyPython 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 17:00:18) [MSC v.1900 64 位 (AMD64)] 在 win32 上E:\Work\Dev\StackOverflow\q050818078\python36x64\python.exeE:\Work\Dev\StackOverflow\q050818078\src\code.py进程已完成,退出代码为 0

    最后一点,命名测试文件代码.py是有点".没有灵感,因为Python 的标准库中有这样一个模块(同时,我将其重命名为 code00.py),但我不想这样做再次所有屏幕截图(包含它).

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

    (I cannot use the executable/web-based installer on my computer)

    I want to install this on my PyCharm. How do I achieve this?

    解决方案

    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.

    这篇关于如何使用“可嵌入的 zip 文件"安装 Python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆