简体   繁体   English

Python 安装:python.exe 的文件路径是什么?

[英]Python Installation: What is file path to python.exe?

I am trying to schedule my python code (.py) to run in Windows 10 using task scheduler.我正在尝试使用任务调度程序安排我的 python 代码 (.py) 在 Windows 10 中运行。 In order to do so, I need to indicate where my python.exe file is located.为此,我需要指出我的 python.exe 文件所在的位置。

I downloaded the latest Anaconda to my Windows 10 machine and run my code in jupyter notebook successfully so I should have python.exe somewhere.我将最新的 Anaconda 下载到我的 Windows 10 机器上,并成功地在 jupyter notebook 中运行了我的代码,所以我应该在某处安装 python.exe。

I cannot find where the "python.exe" file path is stored in my computer.我找不到“python.exe”文件路径在我的计算机中的存储位置。 Thoughts?想法?

Please see sample example below:请参阅下面的示例:

在此处输入图片说明

You can get it quite easily using the os module:您可以使用os模块很容易地获得它:

First open a Python interpreter, not through terminal but directly (there should be a shortcut on your start menu).首先打开一个 Python 解释器,不是通过终端而是直接打开(开始菜单上应该有一个快捷方式)。

Next get the os module:接下来获取 os 模块:

import os

And use the getcwd() method to find it:并使用getcwd()方法找到它:

os.getcwd()

The better way to do it.更好的方法来做到这一点。 If Python is added to path.如果将 Python 添加到路径中。

Open a command prompt window.打开命令提示符窗口。 Not the Python interpreter or open Power Shell and type:不是 Python 解释器或打开 Power Shell 并输入:

where python

Another way to do it is to type python.exe in the file explorer search bar at C: .另一种方法是在C:的文件资源管理器搜索栏中键入python.exe

Get yourself a copy of Search Everything and type python.exe into its search box.为自己准备一份Search Everything并在其搜索框中输入python.exe That will find all Pythons available on your PC.这将在您的 PC 上找到所有可用的 Python。

截屏

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

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