TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

You don't really need a virtualenv

169 pointsby giladover 4 years ago

21 comments

smitty1eover 4 years ago
&gt; things get tricky when it comes to nested venvs<p>Never had such a requirement.<p>Environments, like the interpreter itself, seem a singleton concept.<p>I have used a Makefile that sources different Bash environment variables kept in files in etc&#x2F; within the venv to switch between, say, a Flask and a Gunicorn startup.
评论 #26024944 未加载
评论 #26030155 未加载
Traubenfuchsover 4 years ago
Could someone ELI7 why python is struggling so hard with dependencies and dependency management when in the Java world this is a solved problem and just works with maven, which is working so damn well it last got updated in November 2019, and the biggest fight going is whether you should use gradle as client instead of maven to access the same dependency ecosystem?<p>I had to set up Python projects for some machine learning classes in college and it was a complete mess.
评论 #26024947 未加载
评论 #26024823 未加载
评论 #26025881 未加载
评论 #26024884 未加载
评论 #26025103 未加载
评论 #26036106 未加载
评论 #26025280 未加载
评论 #26026585 未加载
评论 #26040695 未加载
评论 #26026543 未加载
评论 #26036893 未加载
评论 #26035065 未加载
darkteflonover 4 years ago
This was a good article and looks like an interesting project.<p>Regardless of whether or not you choose to _deploy_ with Docker, _developing_ in Docker containers using the VS Code Remote extensions really solved all of Python&#x27;s (and Javascript&#x27;s) annoying packaging problems for me, with the bonus that you also get to specify any additional (non-Python) dependencies right there in the repo Dockerfile and have the development environment reproducible across machines and between developers. YMMV, of course, but I find this setup an order of magnitude less finicky than the alternatives and can&#x27;t imagine going back.
评论 #26024608 未加载
评论 #26022541 未加载
评论 #26024881 未加载
评论 #26024561 未加载
frostmingover 4 years ago
Thanks for giving a look and leaving so many reactions. This project was originally built to experiment on some new PEPs on Python packaging and it turned out working well.<p>1. What does PEP 582 differ from virtualenv, it is just another &quot;virutualenv&quot; The biggest difference, as you can see, is __pypackages__ doesn&#x27;t carry an interpreter with it. This way the packages remain available even the base interpreter gets removed. 2. I prefer Poetry&#x2F;virtualenvwrapper&#x2F;Pipenv It is fine. If you feel comfortable with the current solution you are using, stick with it. I am not persuading that PDM is a better tool than those. Any of the said tools does a great job solving its own problems. PDM, IMO, does good in following aspects:<p>- Plugin system, people can enhance the functionalities easily with plugins - Windows support, PDM has completion support for PowerShell out of the box. Other CLI features also work as good as *nix on Windows.
评论 #26026418 未加载
michaericalriboover 4 years ago
&gt; One day a minor release of Python is out<p>It is decidedly <i>not</i> true that I want to update my venv for every minor version bump!<p>I deploy to a cloud service w&#x2F; a specific version; my package manager is slow to update; I develop collaboratively using a shared container w&#x2F; a fixed version.<p>Updating shared resources with every new release is not always realistic, and that makes it so that I <i>do</i> need (or at least <i>want</i>) to use a virtualenv.
评论 #26025104 未加载
评论 #26024554 未加载
BiteCode_devover 4 years ago
My first attempt, and I get &quot;AttributeError: module &#x27;toml.decoder&#x27; has no attribute &#x27;TomlPreserveCommentDecoder&#x27;&quot;<p>So careful, far from stable.<p>I reported it (<a href="https:&#x2F;&#x2F;github.com&#x2F;frostming&#x2F;pdm&#x2F;issues&#x2F;247" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;frostming&#x2F;pdm&#x2F;issues&#x2F;247</a>) because the project is great and I want it to succeed, but I won&#x27;t put it in prod any time soon. I prefer my package manager to be stable than fancy.<p>It&#x27;s also why I don&#x27;t use poetry and so on in training. There is always some bug that students will encounter later because there are so many config combinations they can encounter, but recent tools have not been as battle tested as we think: the enterprise world is a wild beast.
评论 #26032047 未加载
mkl95over 4 years ago
I recommend virtualenv and virtualenvwrapper. I usually set up a new venv like this:<p>$ mkvirtualenv -a $(pwd) new_venv<p>$ pip install -r requirements.txt<p>When you want to activate this env and cd to the directory where you created it, you can simply do:<p>$ workon new_venv<p>That&#x27;s all you need to know. It just works.
评论 #26024291 未加载
neologover 4 years ago
Sure you can make your own package directory and develop a new package manager to point into it. But what&#x27;s the point when Poetry already exists?
评论 #26022397 未加载
JoshuaRLiover 4 years ago
Happy to see PEP 582 gaining traction, the last attempt I saw in this space was <a href="https:&#x2F;&#x2F;github.com&#x2F;cs01&#x2F;pythonloc" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;cs01&#x2F;pythonloc</a>.
dissentover 4 years ago
Thanks for writing this. I&#x27;ve always felt that virtualenv was bit of a placebo. I still use it from time to time though because others expect it. In fact I have used it this week on MacOS, and was annoyed to find that I can&#x27;t install ipdb to my user packages and still see it in a virtualenv. Seems it&#x27;s either global or local. (I think the --system-site-packages defaulting to off has it backwards, but it is probably reassuring if you don&#x27;t know how the module finder works).<p>Regarding nested virtualenvs, last time I checked there was no such thing. When nested, they always linked back to the system level python, and the cloned python had loads of dependencies on the global system. I&#x27;m not aware of a valid use case for nesting virtualenvs.<p>There is one handy feature of virtualenv that I&#x27;m not sure __packages__ solves though: console_scripts and entry_points. setuptools will automatically create a console script under &#x2F;usr&#x2F;local&#x2F;bin or similar which hooks in your module under site-packages. virtualenv includes a .&#x2F;bin directory and adds it to your path so that these console scripts still work locally. Any thoughts on this?
评论 #26025114 未加载
评论 #26024709 未加载
snicker7over 4 years ago
Yet another python package management tool.
mikkelamover 4 years ago
Man i love the ease of this lib. I&#x27;ve been running between docker, poetry, venvs, and pipenv and they all just SUCK.<p>Is there a best workflow for using this inside a container?
dbsmith83over 4 years ago
Curious, what about environment variables? I like the ability to put my environment variables in my activate script. It seems like if you did things the way the author does, you would need all of your env variables to be global, which could be hazardous
评论 #26026121 未加载
akdor1154over 4 years ago
Interesting idea, and props for implementing something on top of an existing PEP.
dzongaover 4 years ago
props to the author of this tool. based on what I read from the blog, it&#x27;s already a step above poetry, which a lot of people rave about recently, but still not good enough not to not use pip. question is, are we going to be nuking the __module__ folder like we nuke node_modules every now and then ? other than I will become an early adopter of the tools. currently using miniconda for my virtualenvs
评论 #26024679 未加载
cutlerover 4 years ago
As a Ruby and Python developer I often wonder why Ruby doesn&#x27;t need a virtual env. What did Ruby get right that Python didn&#x27;t?
评论 #26023923 未加载
评论 #26022962 未加载
评论 #26025168 未加载
评论 #26023133 未加载
评论 #26022687 未加载
评论 #26022507 未加载
bltover 4 years ago
I struggled with Python dependency hell often until I started using Conda. I wish it were faster, but it rarely surprises me.
评论 #26045347 未加载
globular-toastover 4 years ago
This looks interesting, but personally I don&#x27;t have any problems with virtualenvs. I use pipx to install &quot;global&quot; tools and virtualenvwrapper to make project envs. It all works fine really.
评论 #26025149 未加载
cdavidover 4 years ago
Regarding the installation of self-contained tools, this is a problem already solved by pipx, which is very simple to use. I wished such a system was included as part of official python installers.
pjmlpover 4 years ago
Indeed, I got introduced to Python with version 1.6, and never used virtualenv.
greatgibover 4 years ago
In fact this guy propose to have python be able to work like npm...<p>Looks like a ridiculous idea to me as node and npm dependencies&#x2F;node_modules is completely messy and inefficient.