繁体   English   中英

如何使用已经安装的 Python?

[英]How to use an already installed Python?

我的 PC 上安装了 Plex,它依赖 Python 运行。 我对 Python 一无所知,但我可以看到它正在 Windows 任务管理器中运行。 现在,我还有一些其他不相关的 Python 脚本需要运行,但我不知道如何找到 Python 在我的系统上的位置或如何访问它。

根据如何找到 Python 安装在 Windows 上的位置? ,我应该 go 到我的 Python 解释器找出来,但我不知道那是什么或在哪里。

这对我来说是全新的。 有人可以牵着我的手,指导我如何运行.py 文件吗?

Python 应位于 C:\Program Files\Python 您是否尝试通过命令提示符 (CMD) 或 WindowsPowershell 运行 py 文件? 如果是,那么您可以移动到 py 文件所在的目录,只需在终端中键入 py 文件的名称即可运行它。

如果仍然找不到目录,可以使用 python 解释器并编写:

(您也可以通过键入 python 在 CMD 中打开python然后逐行编写下面的代码,每行后按回车键)

import os
import sys
print(os.path.dirname(sys.executable))

在命令提示符(CMD)中,使用cd path_name(f.example desktop)移入目录,使用cd..移回。 然后,您可以使用dir查看该目录中的文件列表,只需键入文件名,例如python_file并按 Enter 键即可运行它。

(WindowsPowershell 中的语法可能不同)

I will assume you are running on windows,so all you have to do is go to the Window's search option and search Python and you will there is python and then you just have to click it and click on open file location and then you will find the folder of it and your desired python version will be there.Then you just have to left click to go to the properties of it and click on open file location and you will find where you'r python is located and i will assume your python最有可能在 AppData\Local\Programes\Python 文件夹中:)

在 windows 中:打开命令提示符并键入 python,如果它在您的环境变量中设置(它在安装时询问),它将打开 python 解释器。

C:\WINDOWS\system32>python
Python 3.8.1 (tags/v3.8.1:1b293b6, Dec 18 2019, 22:39:24) [MSC v.1916 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>>

要检查其他文件和模块,请尝试下面的解释器。

>>> import sys
>>>
>>> print(sys.path)

执行 python 文件。 只需打开命令提示符和 go 到文件的位置,然后键入python <name_of_python_file>

Plex 提供自己的 python 库。 这是基于 Python 2.7 构建的。 您不需要安装 Python 即可运行 Plex,此时不建议使用 2.7。 您也不能按照您希望的方式使用 Plex 提供的 Python 版本,因为它们不包含可执行文件。

在 Plex 的安装目录中,您将看到两个文件。

  • python27.dll
  • python27.zip

zip 文件夹的内容非常接近 Python 2.7 标准安装中的Lib文件夹。

由于python未安装或未在您的系统路径上可用,因此提供的解决方案均不适合您。 Python can be installed by downloading it directly from Python ( https://www.python.org/downloads/ ), executing the downloaded file, and following the prompts.

安装 Python 的另一种方法是来自 Microsoft Store,适用于 Windows。

查找 Python 安装位置的建议均无效。

正如评论中提到的@tdelaney,即使 Plex 使用 Python 并且它在我的系统中运行,我实际上并没有标准安装它。 我不得不 go 下载它。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM