r/learnpython • • 8d ago

Virtual Environment and Python

I have started learning python and decided to use pycharm as an editor. I want to know anything which will help me in this journey.

My main question is => I don't get "virtual environment" thing with python. I cloned a repo and opened it in pycharm, it says "No python interpreter configured for <repo-name>" and then suggested to create virtual environment.

I want to hear things from experience devs.

thank you.

4 Upvotes

43 comments sorted by

View all comments

1

u/Confident_Hyena2506 8d ago

If you don't have any python then you can't run any python.

And you will need lots of different versions of python for different projects - virtual env is just a way to organise them.

-1

u/Classic-Rate-5104 8d ago

Virtual environments have the drawback of encouraging the use of old (outdated) versions of packages, which in some cases can lead to serious security risks.

4

u/Confident_Hyena2506 8d ago

This is the case with software in general, so I'm not sure what your point is.

If you are referring to linux and it's integral python managed by system, then that is for the system not for your own projects - a point that causes much confusion.

It's just not correct that you can update your python to the latest and use that - this only works for trivial stuff - everything else has dependencies.

-1

u/Classic-Rate-5104 8d ago

Not completely true because i have seen many people building network services based on python packages with severe security problems in docker images. This is not strictly "system" but also not without risks

1

u/nekokattt 7d ago

How is this any different to any other programming language

-1

u/Classic-Rate-5104 7d ago

In other languages libraries have more stable interfaces but many python packages have a different interface every time you look at them. This makes this world more chaotic and unpredictable than other environments. Let me clarify, i like python very much but I wished its package-developers would be more aware of continuity and compatibility

1

u/nekokattt 7d ago

this is anecdotal

1

u/SharkSymphony 6d ago edited 6d ago

We're getting a bit afield here, but I'd drink a soda to that. 😁

I do think there are a sizable number of Python packages now that get it right. But yeah, every long-time Python programmer probably has a list of minor-version-updates-that-weren't debacles etched into their brain.

1

u/rake66 8d ago

Not using virtual environments also has the drawback of encouraging the use of very new versions of packages, which in some cases can lead to serious security risks.

2

u/cdcformatc 8d ago

not using virtual environments also gas the drawback of having your shit break with no warning.

i was once working on a new project and installed some library which required an update of some dependency. then i went to work on a completely different project and to find out it was now broken because a library it used required a different version of that same dependency.

-1

u/Classic-Rate-5104 8d ago

You're absolutely correct. The whole python environment is very "unstable" in the sense that things change constantly. However, if possible, I would trust the debian packages more than the randomly chosen requirements.txt of many packages

2

u/nekokattt 7d ago

Thats fine until breaking changes occur in packages.

Relying on debian packages also removes any build reprodicibility on the basis that you have to always be running something with access to debian repos to be able to run your code in the first place.

1

u/SharkSymphony 6d ago

I don't think I'd agree with this. Yes, you have to consider your version management across projects, but virtual environments themselves don't have an opinion on what versions of packages you use. You can pursue a latest-and-greatest strategy with them as well.