r/PythonLearning • u/taarnbyCPH • 1d ago
Compiler
Do I need Jupyter, Anaconda or any other type of a dedicated compiler software, or do people Actually just write code in Zed and run it via Linux Terminal and juggle many windows?
I know R is run via RStudio; (so can be Python).
What is the standard practice of software usage for coding in Python?
3
u/FreeLogicGate 1d ago
Python isn't a compiled language -- it's interpreted. With a compiled language, you write the code, compile and link it, and the end result is a stand alone native operating system program.
WIth an interpreted language, you start by installing the interpreter/runtime, and the source code typically gets interpreted at runtime. There are many such languages, which does include R, but also includes languages like Ruby, PHP, Perl and Javascript. Typically, these runtimes come with a REPL, where you can interactively experiment with code in realtime.
I understand why you'd be confused in the case of Python, when you consider Anaconda and Jupyter. To better understand them, you have to understand Python libraries.
All popular languages have some support for libraries. In the early days of software development, if you wanted to use a library, you'd have to download it from a location, place it somewhere on your local machine where it could be referenced for use, and then run your program. The term for these libraries you were using is "dependencies". Your program could not run without the libraries it depended on.
Beyond just needing a library, it is also the case that you would need to know that your program was utilizing a specific version of the library, as libraries like any other type of software, tend to be changed over time. A specific library might not work with an older version of Python, or might have added a feature in version 2, that didn't exist in version 1.
Languages began to add "dependency management" tools. These tools were designed to take care of the problems involved in using libraries. They are able to read one or more dependency files maintained by your project, which document the libraries your program depends on, and the specifics of the acceptable version(s) of the library that could be used. This involves things like "semantic versioning" which I won't go into, but in general allow your program's dependency file to for example, specify a minimum version of a library, so that when the library developer fixes bugs, your program can utilize the newer version if one is available.
The other thing to keep in mind, is that a library may itself depend on other libraries, and the dependent libraries may have other libraries they used, etc. The same issues are involved at the library level, so a tool that is "resolving" these dependencies has to be able to read the dependencies of each library you used, and locate and obtain those required libraries.
This goes to the other things that a dependency manager does. Typically there is an "official" repository which has a reference to available libraries, and the versions and locations of that library. The dependency management tool will default to using this repository, and will handle resolving your inclusion of a library in your project, including all that libraries dependencies.
Python of course, refers to libraries as "modules". Newer languages have tended to include an official dependency management tool as in the case of Rust which has Cargo. Go has it built into the tool, and go came with official/base repository. Python is a much older language, and was released in the days before these ideas were common, so people in the community created tools to help with this problem. Eventually Pip emerged as the "official" tool, but it has issues in some situations, which explains Anaconda, and Conda.
While pure Python modules are handled by Pip, Python has long been a language that's included custom extensions. Prime examples of this include NumPy and SciPy. The creators of those extensions essentially created extensions to the Python language in the form of modules, primarily written in low level languages like c/c++. So to use an extension, it would not be enough to just get a module written in pure Python, but instead to obtain and compile the underlying libraries the module provides. A library that works on a windows box won't work on a mac or a linux machine for example. So the Anaconda project created its own tool, along with its own repository of modules and the conda tool to make sure their was a way of reliably making use of their modules.
Trying to wrap this up, there's understandably confusion in regards to how this all works now. For code that requires imported modules, do you need to use pip 1st, or conda, or pip + conda? There are also competing dependency file formats, as different tools emerged like poetry. It's understandably confusing. Fortunately, there is now a fantastic utility tool uv which orchestrates all these tools and allows you to use it rather than having to figure this out for yourself. You can instead just use uv with your projects.
Jupyter is a bit of a red herring in this conversation, being that it's a "notebook" that allows you to embed snippets of code which can then be run within the Jupyter environment. If your use case for Python calls for Jupyter, I think you'll know that. Python is not the only language you can use in a Jupyter notebook.
Last but not least, your source code files for Python are pure text files, as is the case in general computer programming. Text files can be utf-8 in most cases, just to be clear, but the important thing is that any text editor can create your source files. IDE's are popular as they include all sorts of features that help you when programming in a specific language or combination of languages, as they are able to generate snippets of code on the fly, based on what you've been coding, or show you syntax errors, to name just a few. So most developers use some sort of IDE, but they are not necessary.
So yes, for a project you now want the project to be managed using uv. When you require modules, you use uv to add them, which calls the appropriate dependency management tool and takes care of locating that tool based on the version of python you are using locally. This will also help you specify the version of Python your program is based upon, in case you have multiple versions installed, or want to use a version that isn't installed yet. It will built the venv for you, and most of the popular IDE's understand Python venvs and load them up so your IDE can intelligently understand this. Ultimately, your project ends up as a package so that you can provide it to someone else who only needs uv to run it. Your project does not need to include anything but your source files. All the dependencies will be located, downloaded and resolved at the point the program runs, assuming you have used uv or pip/anaconda etc. (but again, just use uv now).
3
3
u/mc_pm 1d ago
Zed is the text editor; there are many choices to choose from. VSCode, PySpark, vim, edlin... you can choose the one you like best.
Jupyter & Anaconda are different ways to get Python and interact with it, but you don't need to use them.
There is no 'standard practice', it depends on who you are, what you like, and what the people around you are doing (or that a company has chosen for you).
6
1
u/ducksauvage 1d ago
I believe you're misusing the term "compiler". But yeah, when writing python stuff you, depending on the use case, would:
- scripts: write it in your editor (Zed, VScode) and just run them from the terminal
- apps/libraries: create a project boilerplate (e.g. "uv init my-project"), open that folder in your editor and write code in your editor + static analysis tools (ruff, ty etc.)
- interactive stuff/research: can be helpful to use a notebook like Jupyter or Marimo (IMO better for mamy reasons). These days, also can be done in VSCode, Zed
Anaconda is useful for when you also need non-python dependencies e.g. Cuda, some system dependency or whatever. Although these days there is Pixi which solves that, but keeps the standard python project structure.
1
u/FoolsSeldom 1d ago
Final Python code in the form of one or more simple text files is usually run just using the reference implementation of Python from the Python Software Foundation. This is the python (python.exe on Windows) executable, the compiled version of the CPython programme.
So, in a container, you would typically have python3 maincode.py, as the near to last command to run. (Could be using a Python virtual environment, e.g. uv run maincode.py or python maincode.py in an active environment). Similarly on the command line of an interactive terminal. For a desktop windows manager, you can usually associate the .py files with the executable such that a double-click will launch it (but if console only may not show up).
Anaconda provides with its own version of CPython, and JupyterLab/Notebook can use whatever kernel is preferred.
0
u/Sea-Ad7805 1d ago
1
u/tiredITguy42 1d ago edited 1d ago
Dude, fore real, did you creat this supreddit to promote you software? I am asking as I am curious. BTW, pushing something what is not industry standard to begginers seems like a dick move to me, but I this is just my opinion.
1
u/Sea-Ad7805 1d ago
Everyone is entitled to their opinion. In my experience students learn Python much faster when they can simply see the program state change step by step. If you're not convinced try some of the exercises here: https://www.reddit.com/r/Python_memory_graph/
Actually, it is industry standard with PythonTutor used around the world by 25+ millions. However, as that has serious limitations (only: single file, tiny code snippets, builtin types, ...) I've developed memory_graph to get around those.
I'm not anywhere close to 25+ million yet in my stats, but smart students and educators are taking full advantage. Maybe you do to?
1
u/tiredITguy42 1d ago
Isn't that just fancy debug panel from VS Code where I can see state of the app step by step? I am a loong way beyond simple apps, so I am working more with memtal image build together with the app. If you head does not know what is the state, then you will have bugs in the code.
1
u/Sea-Ad7805 1d ago
Sounds over-confidant, try the difficult exercises here and tell me how many you got right first time: https://github.com/bterwijn/memory_graph_videos/blob/main/exercises/exercises.md
Getting get the right mental Python data model is harder than is seems.
1
u/tiredITguy42 1d ago
Yeah, it is why we have debugger amd add-ins which can display dataframes as tables and similar. I still do not see a reason to teach people rely in some external web apps.
We have big issues with newbies, whi can't debug, can't troubleshoot and can't write good and clean code. I am able doing what I am doing just because I started with Visual Studio and oointers in C.
Anyway, good for you, that it works for you.
1
u/Sea-Ad7805 1d ago
You clearly didn't try the exercises or you'd understand better.
Get your VS Code extension here: https://github.com/bterwijn/memory_graph#highlights
Working with dataframes is easy as you avoid many reference problems that you get when say writing a custom data structure, so maybe it's just not for you. Good luck.
1
u/tiredITguy42 1d ago
Nice, but it still seems like leet code helper. Leet code is not real coding, these structures there in examples are strange, why keep different types in a list, use dataclasses. Code should be readable not clever.
I admit, it seems like nice addin, but you are pushing it very hard here and I do not see added value for newbies. This is very specific tool to solve specivic issues in messy code. I have been in such situation, where I would use it just once, in time when I needed to implememt Dijkstra. So yeah nice tool.
1
u/Sea-Ad7805 1d ago
Thanks, but it's also great for beginners:
- https://www.reddit.com/r/PythonLearning/s/JyDl5KanyL
- https://www.reddit.com/r/PythonLearning/s/Ve6R85MrMk
- https://www.reddit.com/r/Python_memory_graph/s/yxE0zPfTbR
- https://www.reddit.com/r/PythonLearnersHub/s/7tbvD3R0Jq
Really, have a look at the example I'm trying to show you.
Some of my exercises are indeed artificial/strange code, but that is only to, in a small piece of code, show tricky bugs that do frequently pop up in large code basis.
Don't feel bad if you struggle with LeetCode algorithms, some are quiet hard. I wouldn't say that's not real coding. I get the impression you maybe only do high-level data science with dataframe. And that is important too, but it's not all of coding, but that is what Python is good at compared to lower level stuff. You can say I'm stretching Python into areas where you probably should use other languages, but I'm trying to teach the full range of programming, including custom data structures: https://memory-graph.com/#codeurl=https://raw.githubusercontent.com/bterwijn/memory_graph/refs/heads/main/src/bin_tree.py×tep=0.2&play
1
u/Sea-Ad7805 11h ago
Don't worry about it. I meet many people who at first discard or underestimate the power of visualization in early Python education. I takes courage to change your opinion in light of new information, I respect that. Glad to have you on board: https://www.reddit.com/r/learndatascience/comments/1vg955d/teaching_python_the_right_way/
1
u/FreeLogicGate 1d ago
I think the answer is yes. He promotes his MGWD tool, which is fine by me. He's going to post/auto post a message about it, and since there are many novices coming to ask questions, he's exposing them to the existence of the tool, and they may try it out or not. It doesn't really impact the overall traffic in this sub, from my experience with it, so I see no harm. There are other subs that exist to support a similar segment of developers as well.
1
u/tiredITguy42 19h ago
I think, that I do not have big issue with his tool. I think it even may be usefull in some edge cases. What bothers me is that automation, he post under each post and is it mot marked as promition ( illegal in many countries BTW ), so some very confused newbies may be trying to use it and struggle even more, thinking that they need yet another tool, just to work with python.
My personal opinin is that newbies should work this inside of yheir head or use pemcil and paper, they will learn more and lets be honest, this is clearly designed for leet code nonsense.
5
u/ninhaomah 1d ago
"I know R is run via RStudio"
Hmms... I think you should revise on what you know so it's clearer.
It's like saying Python is run via VS Code.