在 macos 中使用 textmate 执行脚本如下:

#!/usr/bin/env python3

# -*- coding:utf-8 -*-

print("hello, world!!!")

报出错误:env: python3: No such file or directory

改为 env python 就可以顺利执行。

在 TextMate 的 Preferences -> variables 查看环境变量 PATH 的值为:

$PATH:/opt/local/bin:/usr/texbin:/usr/local/bin

在 MacOS 中,python3 的路径为 /usr/local/bin/python3,python 的路径为 /usr/bin/python

系统中的 PATH 环境变量为:

$ echo $PATH

/Users/guli/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

是没错的,包含了 python3 和 python 的路径,那为什么在 textmate 中只能调用 python 而不能调用 python3 呢?

然后搜索到一篇 textmate 的博客:大意是 textmate 没有继承 MacOS 的环境变量设置,因为它没有解析 shell 的启动脚本。所以如果执行的命令在默认 PATH 路径之外的话,需要在 textmate 的设置中添加命令的路径。

好了,那奇怪的点在于,textmate 路径也是对的。为啥还是不行呢。

试了试,有两种方法是可以的:

1,在 python 脚本改写第一行,直接写上python3的路径:

#!/usr/local/bin/python3

# -*- coding:utf-8 -*-

2,在 textmate 的 PATH 设置中,添加python3的命令路径:

$PATH:/opt/local/bin:/usr/texbin:/usr/local/bin:/usr/local/bin/python3

好了,最奇怪的事来了,我后来把这两种改动都还原了,但是也可以执行成功了。

但暂时就这样先,不再研究下去了,先用着,已经花了1个小时折腾这个事情了。

下面是参考的那篇textmate博客文档:

Defining a $PATH

Upcoming changes to OS X have caused us to make some changes in TextMate that have been causing some users to see a env: ruby18: No such file or directory error when running bundle items. This is caused by improper setup of the PATH variable, but lets go over what this variable does and how to correct the issue.

OS X comes with many command line tools that TextMate takes advantage of such as ruby, python, git, etc. To find these programs there is the environment variable PATH which is a list of paths that is used to find the required tools.

Note that while you may already have set the PATH variable for your shell (e.g. bash) it is not inherited in TextMate, as TextMate does not parse your shell setup scripts. For commands that require tools outside the default path list, like the LaTeX typeset command, we normally provide a list of common locations that TextMate should also search, so you normally should not need to change the PATH in TextMate.

To add to the PATH variable inside TextMate open Preferences and go to the Variables section and add a new item with the name of PATH. It is important that the value set augment the existing value instead of replacing it. To do this you should prefix the value with $PATH:. Example values for common uses:

MacPorts: $PATH:/opt/local/bin

Homebrew: $PATH:/usr/local/bin

This post relates to TextMate 2.0 only.

python执行脚本失败恢复环境_Textmate 执行python脚本的错误:env: python3: No such file or directory...相关推荐

  1. python安装beautifulsoup失败_Win10环境下python36安装BeautifulSoup出现错误的解决办法

    说明:win10 64位系统,Python3.6.3 Win10环境下安装BeautifulSoup4貌似没有任何问题,但是当使用时就会报错,错误如下: 通过报错信息到相应的位置去查看文件 try: ...

  2. 尚学python课程---11、linux环境下安装python注意

    尚学python课程---11.linux环境下安装python注意 一.总结 一句话总结: 准备安装依赖包:zlib.openssl:yum install zlib* openssl*:pytho ...

  3. Python基于vs2013开发配置环境出错unsupported python version 3.7解决方案

    Python基于vs2013开发配置环境出错 unsupported python version 3.7解决方案 前提:vs2013+vs2013插件+python 可能网友们在安装完成之后,打开v ...

  4. Mac电脑的python下载、安装和环境配置——JDK+python+pycharm

    Mac电脑的python下载.安装和环境配置--JDK+python+pycharm 之前一直用的windows,换了Mac之后用的还有些生疏,刚好都是重新配置就随手记一下 之前一直用的windows ...

  5. python安装docx库_linux 环境下的python 安装 docx 的过程

    由于linux 系统环境下的python是系统管理员安装好的,所安装的库也是固定的. 如果环境中没有自己要用的库,则需要自己安装.并且只能自己新建一个虚拟环境,让python 运行在新建的虚拟环境中. ...

  6. python 打包 无需安装运行环境_无需Python环境,小白也可以运行的抢票程序

    阅读文本大概需要 5 分钟. 又到周末了,pk 哥抽空对抢票程序作了优化,并把优化后的程序做打包处理,打包后没有 Python 环境的电脑也可以正常运行程序了.前两篇关于抢票的文章没看可点下方链接查看 ...

  7. java远程执行命令报错java.io.IOException: Cannot run program “ifconfig“: error=2, No such file or directory

    直接执行ifconfig没问题,但是在java代码里远程执行ifconfig就找不到命令. session = conn.openSession(); session.execCommand(cmd) ...

  8. redhat6.4执行二进制程序报错:/lib/ld-linux.so.2: bad ELF interpreter: No such file or directory...

    redhat6.4执行二进制程序报错: /lib/ld-linux.so.2: bad ELF interpreter: No such file or directory 原因: 在64位的系统中执 ...

  9. sublime text3安装python插件和flake8_Sublime Text环境配置(Python、Latex、Markdown)及常见问题汇总...

    目录 安装 基本设置 万包之祖 Package Control Python 环境配置 Markdown环境配置 Sublime问题汇总 macOS+Latex环境配置 安装 从官方网站地址下载安装即 ...

最新文章

  1. 应用开发也去中心化?基于BCH的筹款平台Akari-Pages与Lighthouse正面交锋
  2. linux访问底层,LINUX下进程打开的文件怎么和底层磁盘关联的?
  3. SpringMVC深度探险(二) —— SpringMVC概览
  4. STL常用的排序算法
  5. 用ORACHK自己主动化检查数据库系统的健壮性
  6. BeetleX.WebFamily针对Web SPA应用的改进
  7. 2021“MINIEYE杯”中国大学生算法设计超级联赛(2)I love counting(Trie树)
  8. linux文件分别打包命令,Linux文件打包命令
  9. python3实用编程技巧_6.python3实用编程技巧进阶(一)
  10. matlab 追赶法
  11. 一个不到300行的C语言打飞机游戏
  12. 9 个免费的程序员在线简历制作工具
  13. 【06期】单例模式有几种写法?
  14. 中南计算机绘图试题,中南大学计算机绘图试题b答案
  15. 知乎:月薪2~3万,码农怎样度过一天
  16. 【论文笔记】Bullseye Polytope: A Scalable Clean-Label Poisoning Attack with Improved Transferability
  17. Coursera吴恩达机器学习week4笔记
  18. Android仿微信群聊头像合成
  19. Batch Normalization介绍
  20. 【Redis】--- 不同数据结构命令

热门文章

  1. DW(德宾-沃森)统计量临界值表
  2. 解混沌半导体激光器matlab速率方程,半导体激光器速率方程的求解.PDF
  3. 数组根据某字段首字母拼音排序并返回新的数组
  4. 【Go】二、Go流程控制
  5. 数字图像处理,图像的频域变换(四)——K-L变换详解 以及 哈尔变换Haar简介
  6. 分享一个好用的dns
  7. 微信小程序获取用户绑定手机号码完整版(转载)
  8. Excel制作斜线表头的制作
  9. 能量原理与变分法笔记10:虚位移原理
  10. 速印机和复印机的区别是什么?