【问题标题】:The source ~/.profile command throw weird error [closed]源〜/ .profile命令抛出奇怪的错误[关闭]
【发布时间】:2020-02-12 08:09:23
【问题描述】:

我正在尝试重新加载 shell,我在谷歌上搜索了很多,发现下面的命令来修复它。但是当我运行命令时,我得到以下错误python: can't open file './test.py': [Errno 2] No such file or directory

rasminayak@DEBIAN-TEST:~$ source ~/.profile
python: can't open file './test.py': [Errno 2] No such file or directory
rasminayak@DEBIAN-TEST:~$

我也试过了

rasminayak@DEBIAN-TEST:~$ source .bashrc
python: can't open file './test.py': [Errno 2] No such file or directory
rasminayak@DEBIAN-TEST:~$ 

【问题讨论】:

  • 可以分享~/.profile的内容吗?
  • 您能否检查一下您的 .profile 的 line2 上的内容?如果可能,也可以在您的帖子上分享
  • PS4=':${BASH_SOURCE}:$LINENO+' . ~/.profile 将记录每个命令运行的文件和行号,这样您就可以准确地看到错误来自哪里。
  • 也就是说,Stack Overflow 只针对编写软件的问题。配置您的交互式 shell 并不是一项专门与软件开发相关的任务。
  • 您的.bashrc 正在工作目录中寻找文件test.py。它不存在于那里。您应该找出为什么将这一行添加到您的 bashrc 中(如果它不再相关,则将其删除)

标签: python linux bash unix profile


【解决方案1】:

你需要从 .bashrc 中删除 test.py 文件

【讨论】:

  • 是的,这就是问题所在,我认为其中一个别名有test.py。我删除了它,它解决了这个问题。
  • @subm,在 How to Answer 中,请注意 Answer Well-Asked Questions 部分,以及其中有关“与帮助中心定义的编程无关的问题”的条目"。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2018-02-18
  • 1970-01-01
  • 2017-07-25
  • 2018-05-11
  • 1970-01-01
  • 1970-01-01
  • 2015-10-25
相关资源
最近更新 更多