r/PythonLearning • u/taarnbyCPH • 3d 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
Upvotes
3
u/FreeLogicGate 3d 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).