Trying to code on my own machine - Q's

Hello all, noob here, following the Data Science path (17%), intending to complete Full Stack Engineer path next. Codecademy has suggested I learn to code on my own machine so I’ve installed miniconda, jupyter notebook, and gitbash on my windows pc by following the tutorials. I also completed the Command Line course. Everything seems to be working but I think I’m missing some basic concepts.

For example, on the Hurricane Analysis project, I downloaded the linked files and tried opening them in Jupyter Notebook. Opening ‘script.py’ takes me to a text editor window; I don’t see how to run the code I am trying to write. I hoped I could use the cells and other features to help me solve the challenge.

I also tried opening the file ‘script.py’ in git bash using ‘python script.py’ and got:
‘Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases.’ I’m probably missing some components here. The tutorials don’t say much about how to use git bash, just that git bash is better than cmd, though miniconda is recommended and it seems to use windows cmd commands, which I am not familiar with.

I am also studying CS50x, the intro to computer science course and that course tells me the staff doesn’t support windows pc, they all use macOS.

I have an informal mentor who is a senior architect. He tells me his team uses linux/mac and he recommends VS Code. He basically grunted when I told him I was learning on a windows pc, and he didn’t seem familiar with jupyter notebook. I could probably handle the expense of a macbook air but I have no experience with macOS and that seems like another way to fragment my time & efforts this early in the learning process. I spent a few hours today researching this but I think because my questions are so basic I’m not coming up with useful keywords to search.

Is there a best way forward? Ditch the windows PC? Learn cmd on another platform? Should I be able to use jupyter notebooks with the given file ‘script.py’? Am I better off with the integrated environment for now? As you can see, I’m a little lost. I appreciate any feedback or direction.

Given you have Jupyter, this might sound like an odd suggestion. I don’t use any other IDE for Python (save a sandbox on the web). Python IDLE is free from python.org and installs very quickly in the Appdata folder of your Windows user account. Be sure to pin the shortcut to your taskbar for easy access to the interactive shell. When the shell is open, we can create a new file from the File menu, or open files we have saved.

Don’t expect any bells and whistles, just a plain-Jane text editor and the Shell. This is in my view the simplest way to get immersed in Python. When you are more comfortable with the language, then would be the time to look at IDEs.

The installation has a Scripts folder where the executable lives. This is the default location for Saving files, which is also recommended for easy and quick access to your files.

Inside the Scripts folder I have a Shells folder where the code in the interactive shell can be saved for future reference.

20220302.py

is the naming convention I use for shells.

1 Like

Thank you for responding. I have Jupyter notebook because codecademy told me I needed it. However the tutorials with Jupyter only address starting a new notebook so I’m not having any luck actually using it with the given project files. Maybe someone experienced with Jupyter notebook could explain this.

If I were to try using Python IDLE, would the shell use bash or cmd?

I was a bit frustrated after completing the command line course and realizing it was all bash and apparently doesn’t apply to miniconda on windows as recommended by codecademy. There doesn’t seem to be much material on codecademy to learn cmd, which leads me to wonder if I should just avoid Windows until I am more comfortable with the third party tools.

Neither, it has its own interactive shell.

Python 3.10.2 (tags/v3.10.2:a58ebcc, Jan 17 2022, 14:12:15) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.

We can run Python in the CMD terminal, PowerShell or bash.

Ok thanks, I’ll look into that. Shell is a new term for me. I’ve only used the in-browser environments presented in this course and one other course. Since everything I’ve seen here is pushing me to Jupyter notebook, I’ve spent a lot of time trying to work with that and I haven’t tried to learn anything else. I don’t know much Python, but I know even less about command lines!

As a learner, spend some time in the IDLE Shell and Editor. I don’t use any other applications to write and run Python. Mind, I only write example code, not full blown apps. We don’t need to use the command line or any other software to run Python, just IDLE. Forget all the other stuff, for now. Spend the time in Introduction to Python 3 track and focus on the language.

When you install Python, be sure to check, Include PATH. This should make your installation available to Jupyter or any other IDE and prevent reinstalling it.

Your taskbar shortcut to be the exe file. You may wish to create a shortcut to the Scripts folder, too. All your work in one place.

1 Like

Another alternative to Jupyter is to use Google Colab. It’s an app that you can add to your G Drive (like any other Google app). It’s based on Jupyter and is similar but cloud-based. You can write and execute Python in it. Import Python libraries too.
You can also push the Colab notebooks right to GitHub. It’s pretty easy.

2 Likes

Ya’ know, I’ve never tried Colab. Tend to lean on repl.it. Can’t see being on a team at this point. Productivity is everything if you earn your living doing this stuff. “I need that report by 3 o’clock!” is something one will often hear, methinks.

Bottom line is, starting at a comfortable level, off line. A local install of IDLE is purely a no-brainer, if you’re me. No growing pains, no overhead or temptation to contend with. The focus should be on the language, not the IDE, imho.

1 Like

Windows has traditionally had less compatibility with Python but it has improved and conda makes it pretty easy. There’s at least no essential reason to swap over and I say this as someone who prefers the *nix side. You might want to at some point but it’s entirely up to you.

I think it’s worth pointing out here that a normal file.py script is a simple text file that it not immediately compatible with a notebook. A notebook file file.ipynb is more complicated built up of json, html and more; it’s basically fed to the jupyter web application that itself links back to a language “kernel” to run and return from code.

There are routes for some degree of conversion between the two, e.g.

but even copy-pasting bits of a .py script into a new notebook would work.


Why does python script.py not work?

The fact that you can’t run this script directly is quite telling, especially if you’ve installed conda. Are you running the conda prompts (inside the start menu) or are you running gitbash? You’ll need one or the other since conda avoids sticking itself in your PATH directly (so you can’t access it from a plain cmd but you could from a conda prompt initialised cmd).

If you want to use gitbash with conda then there’s a great guide here on the forums- Setting Up Conda in Git Bash

2 Likes

Thank you for pointing out Google Colab. This sounds like a solid option, since I’m already familiar with drive/docs/sheets etc.

1 Like

The fact that you can’t run this script directly is quite telling, especially if you’ve installed conda. Are you running the conda prompts (inside the start menu) or are you running gitbash? You’ll need one or the other since conda avoids sticking itself in your PATH directly (so you can’t access it from a plain cmd but you could from a conda prompt initialised cmd ).

I’m not really running either, as I haven’t figured out how it should work. Conda was installed with Jupyter Notebook by following the tutorials and I’ve gone as far as creating a new notebook for the Frida Kahlo project. As I understand it, conda with Jupyter Notebook should give me everything I need to code on my machine. But when I reached the next project (Hurricane Analysis), I am offered the ‘script.py’ file which doesn’t seem to work with Jupyter Notebook.

Another article suggested I use gitbash so I installed that. I’ve tried using it, but I’m not sure what to do with it. IIRC, gitbash was suggested so I could skip learning cmd. I’m not sure if gitbash is meant to be an alternative to conda or cmd, or just a different tool entirely.

If you want to use gitbash with conda then there’s a great guide here on the forums- Setting Up Conda in Git Bash

Thanks for the link. It looks like this is written for someone in precisely my position. I’ll spend some time with this today. I’m not sure what I want to use, really. I think maybe I’ve found some competing/overlapping instructions in the codecademy material, and I’m not sure what is the best use of my time, so I’m grateful for the guidance shared in this thread.

Yeah there’s a bit of a throw things at the wall and see what sticks approach to getting Python going (it’s better than it was but it’s still confusing). There are several routes to do it with various benefits/drawbacks and it’s quite possible to have more than one working at any one time but they can negatively interact if you’re not careful about it so trying to limit the installs until you’re more comfortable with the ecosystem is probably a good idea (even if that means uninstalling things before adding the next).

Conda is more of a package management system, it’s a tool to help ease installation of certain software. It’s generally geared towards, but not limited to, the data science/analysis side of things and contains it’s own organised packages for Python, R, pytorch and much more. So flip the thinking around with the notebook in that it’s conda that installed or came with the jupyter notebook software as one of many possible packages.

One of the nice things about using it is that you can, if you wish, keep every part of it completely separate to the rest of your system fairly easily which can make managing everything simpler. It’s not essential and there are other ways to do the same thing but it can be very helpful.

Gitbash would be one alternative to cmd (which is indeed quite clunky to use and less popular).

I mentioned it in the previous post but a .py file is not the same as a notebook file, they cannot simply be swapped about without effort. A .py file is for use with the standard python interpreter, a notebook is a third party tool. Many, especially in the data science-y fields find their combination of interactive REPL, markdown and image inclusion helpful.

If you have a .py file you’d want to run in a notebook you can either convert using one of the tools listed above with various caveats or you can literally copy/paste the relevant sections of the .py file into a notebook and run them as you want to.

2 Likes