1

I installed anaconda for python 3.7 in my windows 10 pc.

When I put python in gitBash, it says

bash: python: command not found

How can I use python globally? So I can use python command everywhere.

Shams Nahid
  • 6,239
  • 8
  • 28
  • 39
  • Did you check `Add to PATH` option while installing it? If not then you will need to manually add the PATH. – hygull Jan 01 '19 at 06:14
  • I can not remember. Can I check it somehow now? – Shams Nahid Jan 01 '19 at 06:15
  • Check my answer at https://stackoverflow.com/questions/49142567/conda-not-recognized-as-internal-or-external-after-creating-new-environment/49346022#49346022 and set PATH then try again, check my answer as well for few more steps. I have added picture for Windows 10, it will help you. – hygull Jan 01 '19 at 06:27

4 Answers4

1

you should execute "Anaconda Prompt" and then you can start "python" from there.

it is not recommended to "add to path" during Anaconda installation on Windows 10. So, it's normal python from Anaconda is not in your path.

xudesheng
  • 1,082
  • 11
  • 25
  • Now I can use python from `Anaconda Prompt`. But how can I use it in `gitBash` or vs code integrated terminal? Is it a bad practice? – Shams Nahid Jan 01 '19 at 06:20
  • @ShamsNahid you can check https://code.visualstudio.com/docs/python/environments – xudesheng Jan 01 '19 at 06:21
  • by default, you have "base" already and you can create new virtualenv too. – xudesheng Jan 01 '19 at 06:22
  • I usually use pyCharm but I just have had a quick check on VS code on my Mac and windows 10, it works as expected. please let me know if you still have questions. – xudesheng Jan 01 '19 at 06:26
0

Add python to your path like this:

$ PATH=$PATH:/path/to/python

and do not specify the .exe then you can use it from git bash

Glyphack
  • 876
  • 9
  • 20
0

@Nahid, you can check my answer at Conda not recognized as internal or external after creating new environment.

  • Close already opened terminals.

  • Follow the instructions given in that link.

  • Open new terminal (Git BASH).

  • Type winpty python or python -i (Simply typing python on terminal will not work).

Enjoy and ask/comment here if you face any issue.

hygull
  • 8,464
  • 2
  • 43
  • 52
0

It depends where you installed Anaconda. Unless you have install Linux version of Anaconda(preferable Miniconda), you need to point gitBash to your Windows Python. E.g. in gitBash

alias python='winpty python.exe'

If you want a specific Python the 'winpty fullpath/python.exe' to make it permanent, add that command to your .bashrc

cd ~
touch .bashrc

Then add the command above. Save and restart your terminal.

Similar issue: Python not working in the command line of git bash

Prayson W. Daniel
  • 14,191
  • 4
  • 51
  • 57