sudo/conda/pip/PATH not found on Git Bash - bash

What is the simplest course of action?
Is there an official install guide / link?
Literally nothing in my Git Bash is recognised, e.g.:
$ pip install pandas
bash: pip: command not found
% conda activate
bash: conda: command not found
$ set PATH=%PATH%;C:\Users\dabell\AppData\Local\Programs\Python\Python310
bash: C:UsersdabellAppDataLocalProgramsPythonPython310: command not found
HDS+dabell#PF2DCSXD MINGW64 ~
$ PATH
bash: PATH: command not found
HDS+dabell#PF2DCSXD MINGW64 ~
$ export PATH="$PATH:"C:\Users\dabell\Anaconda3
HDS+dabell#PF2DCSXD MINGW64 ~
$ conda list
bash: conda: command not found
HDS+dabell#PF2DCSXD MINGW64 ~
$ export PATH="$PATH:"C:\Users\dabell\Miniconda3
HDS+dabell#PF2DCSXD MINGW64 ~
$ conda list
bash: conda: command not found
HDS+dabell#PF2DCSXD MINGW64 ~
$ export PATH="$PATH:"C:\Users\dabell\
> conda list
HDS+dabell#PF2DCSXD MINGW64 ~
$ conda list
bash: conda: command not found

You'll probably want to just run the regular windows installer (from the python site - https://www.python.org/downloads/) and then add the appropriate folder with the python and pip binaries to your $PATH system variable.
There are package managers like https://community.chocolatey.org/packages for windows, but as you can see they do not come as standard on windows.

Git bash is just a shell/terminal client to Git, which does (and should) not know what are su, apt-get, pip or anything else, that has no association with git.
su, apt-get and etc. are utility programs, which you invoke from the shell, as commands, and which are available on Linux distributions;
pip is the package installer for Python.
netstat, as an additional example, is a utility software available on Windows OS, from the shell.
None of abovementioned will be available in your git bash, because, again - git bash is just a Git client, not a OS shell.

Related

Bash script fails with Python3.8: command not found

I'm new to bash and scripting in general.
In short, I'm to run a particular build and one of the tasks fails. This is the first time I'm running this build so I was expecting all sort of issues.
The script starts with: #!/usr/bin/env bash
And fails with : python3.8: command not found at line X, which is: python3.8 -m venv $ENV_PATH
I'm using zsh, brew installed.
Which python:
➜ ~ which python3
/usr/bin/python3
➜ ~ which python
/usr/bin/python
Exact version:
➜ ~ python3 --version
Python 3.8.9
I also edited the .zshrc file and added an alias:
alias python3.8='python3'
And it opens up the Python3.8 terminal when I type 'python3.8' now.
What could be the source of this issue? I know I might have messed up a lot of things. I'm also confused with all of these Bash profiles. Using zsh while it loads the default bash? where does it take it's commands from?
Appreciate any help...
You need to source your PATH: Before you call python, you should put:
PATH+=:/usr/bin
The path in the shell script is different from your system path, so you need to source your system path within the shell script.

MacOS PATH issue: which git I am using?

On my macOS Catalina 10.15.5, I have two git installed, one is system default version in folder /usr/bin, one is install by brew in folder /usr/local/bin. The system $PATH env variable in as following, it is obvious /usr/local/bin is listed in front of /usr/bin. However, when I issue git on command line, the git in /usr/bin was executed, rather than the other one. How could this happen? The shell is bash.
lannis20mbp:~ lannis$ echo $PATH
/Users/lannis/anaconda3/bin:/Users/lannis/anaconda3/condabin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/Visual Studio Code.app/Contents/Resources/app/bin
lannis20mbp:~ lannis$ which git
/usr/local/bin/git
lannis20mbp:~ lannis$ whereis git
/usr/bin/git
lannis20mbp:~ lannis$ git --version
git version 2.21.1 (Apple Git-122.3)
lannis20mbp:~ lannis$ /usr/bin/git --version
git version 2.21.1 (Apple Git-122.3)
lannis20mbp:~ lannis$ /usr/local/bin/git --version
git version 2.27.0
If you have added new binaries (executable programs) to your PATH since your shell started, you may need to rehash the lookup tables in your shell. You can do that with:
hash -r
If you want to know how the shell will interpret a given command, it is generally more useful to use type COMMAND rather than which COMMAND because type will also tell you if the command is aliased:
type git
Here is a simple example. First, see that type find and which find give the same result:
which find
/usr/bin/find
type find
find is /usr/bin/find
Next, create an alias for find which masks /usr/bin/find:
alias find='ls'
Now, see that which doesn't tell you what you want to know:
which find
/usr/bin/find
Whereas type does:
type find
find is aliased to `ls'
Read more about the hash, type and other builtins with:
help hash
help type
Notes: hash, rehash, type, builtin, builtins, built-in, built-ins, PATH, which.

Heroku: edit files of a python library that is already installed

Is it possible to edit the files of a python library that is already installed within a heroku environment? Thanks in advance!
You can see the folder where the app is installed on heroku, but I don't you can edit them. You won't have access to a text editor. See these commands:
heroku run bash
~ $ pwd
/app
~ $ ls
...
~ $ vi foobar.txt
bash: vi: command not found
~ $ nano foobar.txt
bash: nano: command not found

Upgrading bash on mac

I've tried to upgrade my bash version on my Macbook Pro (Mojave OS). To do this, I've run:
brew install bash
sudo nano /etc/shells # And then added the new bash shell to the bottom of the list.
chsh -s /usr/local/Cellar/bash/5.0.11/bin/bash
After doing this, bash -version still returns version 3 but echo $BASH_VERSION print's version 5. If I try and make an associative array (I think this isn't present in 3), it works, so I assume I am using the new shell. Why has my bash version not updated?
Although you are running your updated version of bash, the command bash is (without a full path) still pointing to the original bundled version: /usr/bin/bash.
Assuming that you actually need to call the command in this form, then you should check the order of locations in $PATH, and make sure that the bin/ folder with the new bash command is in the $PATH list before /usr/bin. Failing that, make an alias in the shell pointing to the new bash.
brew adds the bash executable to /usr/local/bin/ directory.
I think this should work:
brew install bash
sudo nano /etc/shells # And then add /usr/local/bin/bash to the bottom of the list.
chsh -s /usr/local/bin/bash

conda command not found even though path is exported

I installed anaconda3 into my home directory. This is what I am seeing within the terminal:
and my .bash_profile looks like this:
export PATH="/Users/spotter/anaconda3/bin:$PATH"
So I don't understand why conda is not being recognized. When I navigate to anaconda3/bin there is a file called conda in there, but even when I try to call it within that pathway it is still not found.
Spotter, your path to conda is incorrect.
I'm on High Sierra MAC OS and just installed Anaconda3 via HomeBrew command. I had issue with running :
conda
It'd also give me:
-bash: conda: command not found
I tried running:
export PATH=~/anaconda3/bin:$PATH
but it needs ENTIRE path. so here are the correct steps:
$ nano ~/.bash_profile
Now export the ENTIRE path, in my case it was:
export PATH=/usr/local/anaconda3/bin:$PATH
Exit out and run:
$ source ~/.bash_profile
Then try:
$ conda
it'll output:
$ conda --version
conda 4.4.10
I had to type source ~/anaconda3/bin/activate.
For anyone that landed here that is using a non-standard shell (zsh for example) the installer 5.3.1 currently changes the bash_profile not the current active default terminal.
Just open ~/.bash_profile, find the block that is added by the installer and copy it into your .zshrc file (if using zsh)
in Mac OS, for conda >4,4, the conventional way of exporting path (export PATH="Users/myuser/anaconda3/bin:$PATH") is NOT recommended anymore. First, see what is error message in your terminal in Mac when you type conda --version. If it says zsh conda not found then you are using ZSH terminal, so modifying any bash file is useless. In this case, you need to edit your .zprofile. on the other hand, if you get error like bash conda not found you edit .bash_profile. Lets, say we have zsh error, then type in terminal:
sudo nano ~./zprofile
located your conda.sh file by searching in your finder. Most probably it is in
~/anaconda3/etc/profile.d/conda.sh
(for me it was like: /Users/hasbah/opt/anaconda3/etc/profile.d/conda.sh, but instead of anaconda3, it might be conda)
then you type in .zhprfile this:
. /Users/myuser/opt/anaconda3/etc/profile.d/conda.sh
conda activate base
then you save (ctrl+X and Y when was asked to save) and restart the terminal.
Now if you type conda --version you will see it.
so, in short:
sudo nano ~/.zproflie
. /Users/myuser/opt/anaconda3/etc/profile.d/conda.sh
conda activate base
save ./zproflie file
close terminal
open new terminal
conda --version
Rather than adding the ~/anaconda3/bin to your PATH, you should add
. ~/anaconda3/etc/profile.d/conda.sh
conda activate base
to your .bash_profile or .bashrc, or type that in a shell, if you don't want it to be activated for each shell. This is the recommended way to activate conda since conda 4.4. See: https://github.com/conda/conda/blob/master/CHANGELOG.md#440-2017-12-20

Resources