简体   繁体   中英

python works in cmd, but not in bash

I have a python script that I would like to run while in the MinGW bash environment (inside a bash script)

I have python 3.5 installed and in the PATH.

This is basically what happens when I try to start python in cmd, and then in bash.

C:\Users\mkhoory-test>python
Python 3.5.0 (v3.5.0:374f501f4567, Sep 13 2015, 02:16:59) [MSC v.1900 32 bit (In
tel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> quit()

C:\Users\mkhoory-test>bash
bash-3.1$ python
 - Cannot openbash-3.1$

I'm stumped. What could be the cause of this?

In your .bashrc file, which should be located under C:\\Users\\[Username]\\ you can add an entry for your PATH . If the file is not there, you can add it.

PATH=/c/PathToPythonInstallation

If you have multiple directories to add, use : to delimit each entry, unlike the Windows norm of ; .

If you set it in the .bashrc you'll need to either close and re-open the bash shell, or type source ~/.bashrc to load it up.

You can also temporarily set the path for the lifetime of your shell session by using export like export PATH=/c/PathToPythonInstallation .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM