Anaconda libraries in Python

Let me preface this by saying I’m not talking about Python in Jupyter notebooks. Because…duh, I know I can do that. I say this because I found a few YouTube videos that had titles about using Python in Anaconda with no mention of Jupyter notebooks in the title. But when you started watching them that’s what they meant. One used Spyder which is a browser based Python IDE included with Anaconda. I even saw an article titled “Anaconda Python Tutorial: Everything You Need to Know” and you know what? It didn’t have everything I needed to know. So no answer from them or soup for me! Anywho I had installed Anaconda which included many libraries. I wanted to run existing Python programs that used panda’s and numpy. I guess I had originally installed these libraries globally using pip. The existing python pandas programs were not finding pandas or numpy. The Anaconda download is > 500MB and includes those and many other libraries. So I didn’t want to re-download panda’s and numpy since they were already in Anaconda. Since my bash prompt was showing (base) and typing conda list showed those libraries, I wasn’t sure of the problem at first.

This problem may have been addressed somewhere on the Internet…but I never found an answer! But you know google results can vary drastically depending on how you construct the search. I could google on another day and construct a totally different search and find success! I saw the question asked in a way I assumed matched my question. But the answer didn’t seem to fit my goal.

So this seems maybe a little obvious in hind-site. The solution was revealed to me by seeing how VS Code successfully executed the program. So from the command line I can execute by proceeding the program name with the path of my anaconda bin file like so “~/anaconda3/bin/python program.py”. So in order to run it directly without the prefix I thought all I needed to do was add that to my program #! (shebang as it is called) in my Python program. However I found that, that didn’t work! To make a long story short the shebang didn’t work with the tilde ~, which designates your home directory! So I had to give the full path like #!/home/user/anaconda3/bin/python. Success at last!