The 2nd lesson I'd teach anyone learning Python π will be about using Virtual Environments.
Surprisingly, I've found out that many developers learn about this well into their careers (like I did.)
Here is everything you need to know about Virtual Environments:
π§΅π
In short, Virtual Environments let you deal with dependencies. Basically, these are the libraries that your code needs to function.
(Who remembers "dll hell" back in the day when working with Microsoft products? If you don't, Google the term.)
π
Imagine that you are building your first Python project. You want to load the content of a URL from your code, so you install the "requests" library.
Easy peasy to do using "pip install requests"! See attached image: version 2.24.0 is installed.
π
You finish your project, and all it's good and dandy!
But then, a month later, you decide to work on your second project. It also needs the "requests" library.
The latest version is not 2.24.0 anymore. Now version 3 is available! That's the one you want to use!
π
So, what do you do?
You could upgrade your system to version 3, but then you'll be potentially breaking the first project you built that depends on 2.24.0!
Do you imagine this happening on a server with many more applications running?
π
Obviously, we need a way to deal with this, so enter virtual environments.
This first step for every new project is to create a virtual environment for it.
Some people have a central location where they store all of these. I prefer to store them in the project folder.
π
Using the built-in "venv" module in Python3 we can create a new virtual environment. In this case, I'm creating it inside the project folder.
Then, using "source" I can activate this environment.
At this point, we have full isolation for our project.
π
Ar this point, if we install any libraries, they will be installed within the environment we are in, and will never mess with the libraries installed at the system level.
This is great!
(Make sure you add the .venv folder to .gitignore.)
π
This covers the basics of why you want virtual environments in your life.
If you want to get further, take a look at @realpython's "Python Virtual Environments: A Primer" article.
Look at the attached video. A company using this tool will execute 100x faster than everyone else. There's simply no match for how fast AI can transform what you do.
I'm working here with @PromptQL. They will help you build a reasoning AI that is specialized to your business.
This makes an ocean of difference:
β’ Connect to all of your data
β’ Build a massive knowledge graph
β’ Incorporate your unique know-how
β’ Learn over time
The learning part is the thing that blew my mind:
You can teach the system how to interpret your data and how you prefer things to be done.
This knowledge can be reviewed, edited, and deployed so everyone at your company starts using the new version of the model.
If you have a list of things you've always wanted to solve, let an agent do them:
β’ Refactor code and ensure tests still run
β’ Find and fix bugs
β’ Close open tickets from your backlog
β’ Update documentation
β’ Write tests for untested code
β’ You can use it with any of the major models (GPT-X, Gemini, Claude)
β’ It has an option to Chat and Edit with the model
β’ It has an Agent mode to make changes to the notebook autonomously