【问题标题】:How to run files in the working directory through Git Bash and Python如何通过 Git Bash 和 Python 运行工作目录中的文件
【发布时间】:2020-09-20 07:10:54
【问题描述】:

我在运行 Python 3 时遇到了一些问题,我通过 Git Bash 安装了 Anaconda。我可以通过输入python 来访问交互环境,但无论何时输入:

python webscraper.py

我明白了:

C:/Users/[My username]/anaconda3/python.exe: can't open file 'webscraper.py': [Errno 2]
No such file or directory

当我遇到这些错误时,Python 文件位于我当前工作的目录中。通过 Anaconda 到我的 Python 版本的路径看起来也是正确的。我之前可以在 Bash 中测试脚本,但必须重新安装它才能解决其他问题。

【问题讨论】:

  • 你激活环境了吗?可以分享一下目录的内容吗?

标签: python bash anaconda git-bash


【解决方案1】:

首先,检查你是否使用了正确的python:

which python # in your git bash session

然后用文件的完整绝对路径名进行测试,as described here:

python /full/path/to/webscrapper.py

【讨论】:

    猜你喜欢
    • 2019-02-25
    • 1970-01-01
    • 2011-11-03
    • 2021-07-07
    • 2014-05-17
    • 2020-08-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多