1

我最近安装了 python3.3.2 的 /usr/local 副本,当确信它是可靠的时,在 /usr 下重新安装并删除了 /usr/local 版本。当我将可执行文件作为 /usr/bin/python3.3 运行时,一切都很好,但是当我将它作为“python3.3”运行时,我收到以下消息:

> python3.3
bash: /usr/local/bin/python3.3: No such file or directory

'which' 找到 /usr/bin/python3.3。我做了一个“set -u”和“set echo”,试图弄清楚发生了什么但没有成功。bash 是如何进入这里的?

谢谢你。史蒂夫·S。

4

2 回答 2

2

shell 仍然会记住您的可执行文件,就好像它已完成哈希一样:

hash: hash [-lr] [-p pathname] [-dt] [name ...]
    Remember or display program locations.

    Determine and remember the full pathname of each command NAME.  If
    no arguments are given, information about remembered commands is displayed.

      -r                forget all remembered locations

运行hash -r而不需要重新启动你的 shell 可以解决这个问题。

更新:实际上,shell 也不仅仅通过运行哈希来记住它。也许当你尝试执行它或做类似type -P prog的事情时,shell 会记住它。这是我在测试中遇到的错误,我没有运行w

bash: /usr/local/bin/w: No such file or directory

hash -r修复它。

于 2013-09-10T18:30:27.590 回答
0

似乎bash正在缓存python3.3某个地方的先前位置。尝试关闭您的 shell 并再次登录 - 这应该会清除缓存并允许bash获取python3.3.

于 2013-09-10T18:10:14.213 回答