🪟 Windows TippsMicrosoft to Hold Surface and Windows Event on October 7(16.09.2026 um 18:25 Uhr)
🪟 Windows TippsNissan bringt seinen Verkaufsschlager Kicks nach Europa(16.09.2026 um 16:34 Uhr)
🪟 Windows ServerBrowser: Firefox 156 bekommt Werbeeinblendungen - Golem.de(16.09.2026 um 17:14 Uhr)
🪟 Windows TippsMicrosoft to Hold Surface and Windows Event on October 7(16.09.2026 um 18:25 Uhr)
🪟 Windows TippsNissan bringt seinen Verkaufsschlager Kicks nach Europa(16.09.2026 um 16:34 Uhr)
🪟 Windows ServerBrowser: Firefox 156 bekommt Werbeeinblendungen - Golem.de(16.09.2026 um 17:14 Uhr)
1 Tag Serie
🎥 Podcasts 🕛 vor 6 Jahren 3 Min Lesezeit
0

HPR3072: The joy of pip-tools and pyenv-virtualenv

↗ Quelle (hackerpublicradio.org)
🗣️ Stimme:
📑 Inhaltsübersicht

TL;DL: What I end up recommending is that you use pip-tools for your dependency management needs, and pyenv-virtualenv for your environment management needs. In the show I explain why you would want these things.



I talk about these tools:








  • I also owe you a show on my awesome bash prompt that shows me which environment I am in.

Install pyenv and pyenv-virtualenv



CODE
git clone https://github.com/pyenv/pyenv ~/.pyenv
git clone https://github.com/pyenv/pyenv-virtualenv ~/.pyenv/plugins/pyenv-virtualenv


Add to ~/.bash_profile:



CODE
export PYENV_ROOT=$HOME/.pyenv
export PATH=$PYENV_ROOT/bin:$PATH


Add to ~/.bash_profile (optional):



CODE
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"


The optional bits provide you with the pyenv shell functionality for setting a session-specific Python version, and automatic activation of the virtualenv. Most of the time you don’t need activation, scripts and commands run just fine via the shims, but some tooling around Python may sometimes need to know which virtualenv you’re in.



Run the export and eval lines in your shell to have the configuration work immediately. Alternatively, do su - yourusername to login to a new session that runs the profile. The - is important.



You might be able to get away with just opening a new tab or window in your terminal. Whether that runs the profile depends on your settings.



Set up your pyenv virtualenv for your project



CODE
# Creates the virtualenv named my-project-env using 
# the python named system (your system default python)
pyenv virtualenv system my-project-env
cd /path/to/my-project
pyenv local my-project-env


Your system Python may or may not work for this. You might have to install pip and virtualenv. It might still break with some message about ensurepip failing (currently both Nix (20.09pre) python and Ubuntu (18.04) python are failing for me, and older Anaconda pythons also had a broken venv). In that case, use pyenv to install a Python that works, and use that instead of the system python:



CODE
pyenv install miniconda3-latest
pyenv virtualenv miniconda3-latest my-project-env
cd /path/to/my-project
pyenv local my-project-env


Install pip-tools



You’ll want to do this inside the virtual environment that you want to manage. Don’t install pip-tools globally.



CODE
cd /path/to/my/project
# And, assuming you have the shims on your $PATH
# and you set the pyenv local as shown previously
python -m pip install pip-tools


Now put your requirements in requirements.in, one on each line, in the form you would give them to pip on the command line:



CODE
somepackage >=3, <4
otherpackage <7


Compile requirements.in to a requirements.txt:



CODE
python -m piptools compile


You could run the shorter command pip-compile for convenience, but using the long form with -m looks it up through your configured Python, and makes it less likely for you to surprise yourself and run a tool in a different virtualenv than you expected. Same with python -m pip above.



Your requirements.txt will look something like this:



CODE
otherpackage==6.9.3          # via -r requirements.in
somepackage==3.4.2 # via -r requirements.in
transitivedependency==2.7.6 # via somepackage


It helpfully tells you where everything is from!



Now to actually install these things you python -m pip -r requirements.txt.



Now you’re good to go! Happy hacking!

Vollständiger Original-Artikel
Den kompletten Beitrag mit allen Details direkt auf hackerpublicradio.org lesen.
↗ Original-Artikel auf hackerpublicradio.org lesen
Wie bewertest du diesen Beitrag?
1 Klick Feedback
Teilen mit Netzwerk & Team:

Community-Analysen & Experten-Meinungen 0

Verfasse deine eigene Analyse, teile Workarounds oder diskutiere diesen Vorfall im Blog.
Noch keine Community-Analyse verfasst. Markiere einen Textabschnitt oder klicke oben auf Eigene Analyse verfassen“!
Community Pulse: Relevanz-Einschätzung
1 Klick Experten-Votum
🔴 Akute Relevanz 0%
🟡 In Evaluierung 0%
🟢 Keine Auswirkung 0%
Spannende Innovation 0%
Verwandte Story-Cluster & Quellen (Vektor-KI)
Port 8095 Engine
1 Quelle
Microsoft to Hold Surface and Windows Event on October 7
1 Quelle
Thrustmaster's new flight stick is a heavy and authentic A-10C HOTAS replica for PC simulator fans who crave digital dogfights
1 Quelle
Nissan bringt seinen Verkaufsschlager Kicks nach Europa
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten HPR3072: The joy of pip-tools and pyenv-virtualenv

Thematisch verwandte Begriffe: HPR3072, piptools, pyenvvirtualenv · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...