如何通过 Git Bash 和 Python 在工作目录中 运行 文件
How to run files in the working directory through Git Bash and Python
我遇到了一些问题 运行 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:
which python # in your git bash session
然后用文件的完整绝对路径名测试,as described here:
python /full/path/to/webscrapper.py
我遇到了一些问题 运行 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:
which python # in your git bash session
然后用文件的完整绝对路径名测试,as described here:
python /full/path/to/webscrapper.py