Problems installing and running python through git bash

Hi guys,

I’m working through the data science career track courses and have got to a project that requires me to setup and run my own python environment (link to project is here: https://www.codecademy.com/paths/data-science/tracks/dspath-python-unit-project/modules/dspath-brute-force-lr/informationals/pwp-linear-regression).

Following instructions from a previous course, I have already installed gitbash as my command line tool and followed the instructions for installing miniconda python distribution.

However once installed, I could not access python through gitbash, I just keep getting an “access denied” error when I attempt this.

I have fully uninstalled both gitbash and miniconda and am going to attempt the setup again, however if anyone could offer some advice or instructions about how to go about this it would be really helpful. A lot of the documentation on codecademy appears to be out of date (it is referencing older versions of gitbash and python etc).

Ive done a small course on bash so would prefer to keep using this as my command line, however if there is a better / easier way to set up a python environment, im open to suggestions.

Hi @ashleyhowe7359274843,

Welcome to the forums!

When you download and install Anaconda or Miniconda, they don’t automatically add the bundled version of Python to the path where Git Bash will recognize it. Typically I think a lot of people on Windows end up using Anaconda Prompt (which comes with Anaconda/Miniconda on Windows), but if you’d like to continue using Git Bash for your command line, I recently wrote a fairly in-depth post on how to do it here:

2 Likes

Mate, this is brilliant. Absolute lifesaver. I’ll try this all later but looks like exactly what I need! Was dreading trying to explain this on stackoverflow!

Thanks again!

3 Likes

No problem. Let me know if you have any questions!

1 Like

Hi again!

Was hoping you could point me in the right direction. So im starting to write my own python scripts on my machine locally rather than through the guided tutorials.

Just really looking for some advice on how I should be doing this. I’m currently writing all my script in a text editor called brackets which I quite like and then just running the files manually in conda using git bash.

I’m coming from a JS background, and this all feels a bit… strange. Is there something I should be looking at to write and compile script in the same place?

Very aware this question might sound a bit ridiculous, I just want to make sure I’m not shooting myself in the foot or something.

Yes, that’s exactly how you would do it. You write the script in a text editor, then you run it from the terminal (Git Bash, PowerShell, CMD, etc.) using the command python my_script_name.py. Obviously, you would use the actual name of your file in place of my_script_name.

I’ve never used the Brackets text editor, but many text editors have extensions or plugins that allow you to pull up your terminal inside of the editor itself. I have personally used such extensions in both Atom and VS Code, but VS Code is my primary text editor. I’m fairly certain that Brackets has extensions that can do the same thing. The main advantage of doing this is that you don’t have to open up a separate terminal window.

Some text editors also have an option to run the active file with the click of a button, which would do the same thing as typing the command to run the file. The only difference is you wouldn’t have to type anything.

If you’ve only worked with browser-side JavaScript, I know that this may seem a little strange, but this is typically how it is done with other programming languages outside of HTML, CSS, JavaScript and PHP, so it’s good practice :slight_smile:

EDIT: I should also mention that if you are working on Data Science-y stuff Jupyter notebooks are another great option. In Jupyter notebooks you can run your code one “cell” at a time, rather than running an entire script. Jupyter notebeooks also make the output of a Pandas DataFrame look the way they do on Codecademy, which is much nicer than how they appear in the terminal.

Thats perfect, thank you!

Ive used jupyter a few times now to good effect, its really useful!

1 Like