pyth命令

Summary: When you type script.py at the Command Prompt on Windows, the Python executable used to run the script is not the first python.exe file found on your PATH, it is the the executable that is configured to run .py files when you double-click on them, which is configured in the registry.

摘要:在Windows的命令提示符下键入script.py时,用于运行脚本的Python可执行文件不是在PATH上找到的第一个python.exe文件,而是配置为在以下情况下运行.py文件的可执行文件您双击它们,它在注册表中配置。

I ran into a strange problem on Windows recently, when I was trying to run one of the GDAL command-line Python scripts (I think it was gdal_merge.py). I had installed GDAL in my conda environment, and gdal_merge.py was available on my PATH, but when I ran it I got an error saying that it couldn’t import the gdal module. This confused me a bit, so I did some more investigation.

最近,当我尝试运行GDAL命令行Python脚本之一(我认为是gdal_merge.py )时,我在Windows上遇到了一个奇怪的问题。 我已经在gdal_merge.py环境中安装了GDAL,并且PATH上存在gdal_merge.py ,但是运行它时出现错误,提示它无法导入gdal模块。 这让我有些困惑,因此我进行了更多调查。

I eventually ended up editing the gdal_merge.py script and adding a few lines at the top

我最终结束了对gdal_merge.py脚本的编辑,并在顶部添加了几行

import sys
print(sys.prefix)
print(sys.executable)
print(sys.path)

This showed me that the script was being run by a completely different Python interpreter, with a completely separate site-packages folder – so it was hardly surprising that it couldn’t find the gdal library. It turns out that this ‘other’ Python interpreter was the one installed automatically by ArcGIS (hint: during the ArcGIS setup wizard, tell it to install Python to c:ArcPython27, then it’s easy to tell which is which). But, how could this be, as I’d removed anything to do with the ArcGIS Python from my PATH…?

这向我展示了该脚本是由一个完全不同的Python解释器运行的,具有完全独立的site-packages文件夹-因此,找不到gdal库不足为奇。 事实证明,这个“其他” Python解释器是由ArcGIS自动安装的(提示:在ArcGIS安装向导中,告诉它将Python安装到c:ArcPython27 ,然后很容易知道是哪个)。 但是,这是怎么回事,因为我从PATH删除了与ArcGIS Python有关的任何内容?

After a bit of playing around and Googling things, I found that when you type something like gdal_merge.py at the Command Prompt it doesn’t look on your PATH to find a python.exe file to execute the file with…instead it does the same thing as it would do if you double-clicked on the Python file in Explorer. This is kind of obvious in retrospect, but I spent a long time working it out!

经过一番gdal_merge.py和谷歌搜索之后,我发现当您在命令提示符下键入gdal_merge.py之类的gdal_merge.py时,它不会在您的PATH上查找要执行该文件的python.exe文件……而是与在资源管理器中双击Python文件时的操作相同。 回想起来,这很明显,但是我花了很长时间来解决它!

翻译自: https://www.pybloggers.com/2016/03/how-to-set-the-python-executable-used-to-run-py-files-from-the-command-line-on-windows/

pyth命令

pyth命令_如何:在Windows上设置用于从命令行运行.py文件的Python可执行文件相关推荐

  1. 你如何在java中获取线程堆_如何在Windows上获取未在控制台中运行的Java进程的线程和堆转储...

    问题 我有一个Java应用程序,我从控制台运行,然后控制台执行另一个Java进程.我想获得该子进程的线程/堆转储. 在Unix上,我可以做akill -3 但是在Windows AFAIK上获取线程转 ...

  2. cmd命令行窗口运行py文件

    文章目录 一.cmd是什么? 二.cmd命令行窗口 运行py文件 一.cmd是什么? cmd是指 命名提示符,是在操作系统中,提示进行命令输入的一种工作提示符. windows环境下,命令行程序为 c ...

  3. [debug] 命令行窗口运行.py文件,报错No module named XXX

    问题描述: 在PyCharm中运行.py文件正常,在命令行运行.py文件报错"No module named XXX" 原因分析 说到底是搜索路径的问题. PyCharm中运行的时 ...

  4. linux设置默认终端模拟器,ubuntu终端默认设置_在Ubuntu Linux上设置默认终端模拟器...

    ubuntu终端默认设置_在Ubuntu Linux上设置默认终端模拟器 ubuntu终端默认设置_在Ubuntu Linux上设置默认终端模拟器 ubuntu终端默认设置 Ubuntu has a ...

  5. Windows上设置Docker共享盘符

    Windows上设置Docker共享盘符 Docker中的settings里的Shared Drives 选择对应盘符后,点击Apply后无法生效,没办法选择对应盘符进行分享. Exceptions: ...

  6. Windows上的实用CMD命令

    Windows上的实用CMD命令 查看系统信息是x64位 查看电脑基本诊断信息 检查电脑支持的最大运行内存 查看内存信息 查看Windows电脑上次的启动时间 查看显卡信息 查看电脑当前的用户名 查看 ...

  7. 在windows上设置代理服务器

    在windows上设置代理服务器 1.安装Apache环境 下载地址:http://httpd.apache.org/docs/current/platform/windows.html#down 只 ...

  8. 【Windows下设置全局以管理员身份运行cmd】

    Windows下设置全局以管理员身份运行cmd 原理是修改注册表,下面是注册表文件的内容. 将下面代码保存到文本中,并重命名为cmd.reg.双击,可设置为任意位置打开命令行都是管理员身份 Windo ...

  9. Windows中使用命令行调用py文件

    1.新建一个py文件 进入你需要保存的文件位置,如E盘 进入E盘后右键,选择新建文本文件 打开新建的文档后,输入python代码,保存 保存后的文本文档修改文件名,后缀改为.py,如 test.py ...

最新文章

  1. Halcon算子翻译——dev_set_line_width
  2. C++ 对TXT 的串并行读写
  3. Ubuntu下的固件分析Binwalk的安装
  4. ArcGIS Engine 编辑- ITask
  5. css border渐变_css边框渐变
  6. libcurl overview
  7. 反解析Navicat ncx加密后的密码(并导入到dbeaver)
  8. iphone电压测试软件,电压电击iPhone结果会怎样? 通过测试后, 照样可以正常开机...
  9. Pytorch 多GPU数据并行(DataParallel)
  10. Python实现异方差检验(statsmodels)
  11. php saas,saas系统是什么
  12. 淘宝详情页排版布局怎么做?大神导航,一个神奇的网站,从此开启大神之路!
  13. Linux操作系统基础之用户管理
  14. 【kernel exploit】CVE-2022-2588 Double-free 漏洞 DirtyCred 利用
  15. 2023年2月的十篇深度学习论文推荐
  16. POI-Excel导入与导出
  17. 微信小程序练手项目-音乐播放器
  18. 廊坊市计算机考试题库,河北省廊坊市2018_2019学年高二物理下学期期中试题(含解析)...
  19. 新版本 chrome 手机浏览器关闭为您推荐的文章方法
  20. Glade的简单使用说明+例子(一)

热门文章

  1. 高考志愿填报选专业,女孩子适合的十大职业
  2. Python爬虫入门-python之jieba库制作词云图
  3. javascript网页设计期末作业 购物网站
  4. 逼自己养成成长型思维模式
  5. struts2文件上传和下载
  6. linux文件安全与权限
  7. AD16弹出错误对话框
  8. MOS管当开关控制时,为什么一般用PMOS做上管NMOS做下管?
  9. 双系统android,如何在Android手机上实现双系统
  10. BZOJ 4316: 小C的独立集 仙人掌 + 树形DP