-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b36908b
commit a95fe46
Showing
95 changed files
with
702 additions
and
4,097 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
content/posts/2024-09-29-bpython-with-multiple-virtual-environments.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
--- | ||
title: Using one bpython with multiple virtual environments | ||
author: Alex | ||
type: posts | ||
date: 2024-09-29T20:49:33+02:00 | ||
url: /posts/bpython-with-multiple-virtual-environments/ | ||
categories: | ||
- Tutorial | ||
tags: | ||
- Python | ||
- TIL | ||
- venv | ||
- REPL | ||
--- | ||
|
||
I finally realized that I should change the default Python REPL. There are many REPLs that offer a much better experience—[ipython](https://ipython.org/), [bpython](https://bpython-interpreter.org/), and [ptpython](https://github.com/prompt-toolkit/ptpython) are probably the most well-known. In the past, I used ipython because I worked on many projects that involved Jupyter notebooks, so it came essentially for free whenever I installed the necessary packages. | ||
|
||
However, in recent years, I've been working on a lot of projects that don't rely on Jupyter, meaning ipython wasn’t installed by default. This meant I always had to manually install it in any virtual environment where I wanted to use it—which I didn’t like, as I prefer to keep only project-specific dependencies in a virtual environment. | ||
|
||
As a result, I relied on the plain old `python` REPL, with all its shortcomings—especially the difficulty of pasting code snippets (which, thankfully, will be improved with [Python 3.13](https://docs.python.org/3.13/whatsnew/3.13.html#whatsnew313-better-interactive-interpreter)). | ||
|
||
Today, I started wondering if there was a way to use a REPL like `bpython` in every environment I have. You can install it once with [`pipx`](https://github.com/pypa/pipx) and use it everywhere, but it won't find any packages by default. While searching online, I came across a promising post on [Stack Overflow](https://stackoverflow.com/a/22182421). Although the post was from 2014 and the exact approach didn't work, with a bit of fiddling, I found a solution that seems to work. I added the following function to my `.zshrc`: | ||
|
||
|
||
```zsh | ||
function bp() { | ||
if test -n "$VIRTUAL_ENV" | ||
then | ||
PP=".$(python -c 'import sys; print(":".join(sys.path))')" | ||
PYTHONPATH=${PP} bpython "$@" | ||
else | ||
bpython "$@" | ||
fi | ||
} | ||
``` | ||
|
||
Now, I can simply type `bp`, and it will either start `bpython` directly or, if a virtual environment is active, it will set the `PYTHONPATH` to include the venv directory before starting the REPL. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,67 +1,7 @@ | ||
<!DOCTYPE html> | ||
<html><head lang="en"> | ||
<meta charset="utf-8" /> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"><title>Article - Alex' Blog</title><meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<meta name="description" content="" /> | ||
<meta property="og:image" content=""/> | ||
<link rel="alternate" type="application/rss+xml" href="https://dfghj.de/categories/article/index.xml" title="Alex' Blog" /> | ||
<meta property="og:title" content="Article" /> | ||
<meta property="og:description" content="" /> | ||
<meta property="og:type" content="website" /> | ||
<meta property="og:url" content="https://dfghj.de/categories/article/" /> | ||
|
||
<meta name="twitter:card" content="summary"/> | ||
<meta name="twitter:title" content="Article"/> | ||
<meta name="twitter:description" content=""/> | ||
|
||
|
||
<link href="https://dfghj.de/css/fonts.2c2227b81b1970a03e760aa2e6121cd01f87c88586803cbb282aa224720a765f.css" rel="stylesheet"> | ||
|
||
|
||
|
||
<link rel="stylesheet" type="text/css" media="screen" href="https://dfghj.de/css/main.ac08a4c9714baa859217f92f051deb58df2938ec352b506df655005dcaf98cc0.css" /> | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<link rel="stylesheet" type="text/css" href="https://dfghj.de/css/carousel.7246d67ed223552bcaacc5e2e16718046d961485b18484de18ab08df89eb9988.css"> | ||
|
||
</head> | ||
<body> | ||
<div class="content"><header> | ||
<div class="main"> | ||
<a href="https://dfghj.de">Alex' Blog</a> | ||
</div> | ||
<nav> | ||
|
||
|
||
</nav> | ||
</header> | ||
|
||
|
||
<h1>Entries tagged - "Article"</h1> | ||
|
||
|
||
<ul class="posts"><li class="post"> | ||
<a href="/quickfolders-a-bitbar-plugin/">QuickFolders – a BitBar plugin</a> <span class="meta">Feb 10, 2017</span> | ||
</li><li class="post"> | ||
<a href="/lametric-firmware-1-7-5/">LaMetric Firmware 1.7.5</a> <span class="meta">Jan 31, 2017</span> | ||
</li></ul> | ||
<footer> | ||
<div style="display:flex"></div> | ||
<div class="footer-info"> | ||
2023 <a | ||
href="https://github.com/athul/archie">Archie Theme</a> | Built with <a href="https://gohugo.io">Hugo</a> | ||
</div> | ||
</footer> | ||
|
||
|
||
</div> | ||
</body> | ||
</html> | ||
<!doctype html><html><head lang=en><script src="/livereload.js?mindelay=10&v=2&port=1313&path=livereload" data-no-instant defer></script><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><title>Article - Alex' Blog</title><meta name=viewport content="width=device-width,initial-scale=1"> | ||
<meta name=description content><meta property="og:image" content><link rel=alternate type=application/rss+xml href=http://localhost:1313/categories/article/index.xml title="Alex' Blog"><meta property="og:url" content="http://localhost:1313/categories/article/"><meta property="og:site_name" content="Alex' Blog"><meta property="og:title" content="Article"><meta property="og:locale" content="en_us"><meta property="og:type" content="website"><meta name=twitter:card content="summary"><meta name=twitter:title content="Article"><script src=http://localhost:1313/js/feather.min.js></script><link href=http://localhost:1313/css/fonts.2c2227b81b1970a03e760aa2e6121cd01f87c88586803cbb282aa224720a765f.css rel=stylesheet><link rel=stylesheet type=text/css media=screen href=http://localhost:1313/css/main.5cebd7d4fb2b97856af8d32a6def16164fcf7d844e98e236fcb3559655020373.css><link id=darkModeStyle rel=stylesheet type=text/css href=http://localhost:1313/css/dark.d22e2a2879d933a4b781535fc4c4c716e9f9d35ea4986dd0cbabda82effc4bdd.css disabled><link rel=stylesheet type=text/css href=http://localhost:1313/css/carousel.7246d67ed223552bcaacc5e2e16718046d961485b18484de18ab08df89eb9988.css></head><body><div class=content><header><div class=main><a href=http://localhost:1313/>Alex' Blog</a></div><nav><a href=/>Home</a> | ||
<a href=/posts>All posts</a> | ||
<a href=/tags>Tags</a> | ||
| <span id=dark-mode-toggle onclick=toggleTheme()></span> | ||
<script src=http://localhost:1313/js/themetoggle.js></script></nav></header><h1>Entries tagged - "Article"</h1><ul class=posts><li class=post><a href=/posts/quickfolders-a-bitbar-plugin/>QuickFolders – a BitBar plugin</a> <span class=meta>Feb 10, 2017</span></li><li class=post><a href=/posts/lametric-firmware-1-7-5/>LaMetric Firmware 1.7.5</a> <span class=meta>Jan 31, 2017</span></li></ul><footer><div style=display:flex><a class=soc href=https://github.com/alex-ruehe rel=me title=GitHub><i data-feather=github></i></a> | ||
<a class=border></a></div><div class=footer-info>2024 <a href=https://github.com/athul/archie>Archie Theme</a> | Built with <a href=https://gohugo.io>Hugo</a></div></footer><script>feather.replace()</script></div></body></html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1 @@ | ||
<?xml version="1.0" encoding="utf-8" standalone="yes"?> | ||
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"> | ||
<channel> | ||
<title>Article on Alex' Blog</title> | ||
<link>https://dfghj.de/categories/article/</link> | ||
<description>Recent content in Article on Alex' Blog</description> | ||
<generator>Hugo -- gohugo.io</generator> | ||
<language>en-us</language> | ||
<lastBuildDate>Fri, 10 Feb 2017 13:23:47 +0000</lastBuildDate> | ||
<atom:link href="https://dfghj.de/categories/article/index.xml" rel="self" type="application/rss+xml" /> | ||
<item> | ||
<title>QuickFolders – a BitBar plugin</title> | ||
<link>https://dfghj.de/quickfolders-a-bitbar-plugin/</link> | ||
<pubDate>Fri, 10 Feb 2017 13:23:47 +0000</pubDate> | ||
<guid>https://dfghj.de/quickfolders-a-bitbar-plugin/</guid> | ||
<description>I’m a big fan of BitBar, an application that allows you to “Put anything in your Mac OS X menu bar” (macOS nowadays). People have already created more than 250 plugins which allow you to show plenty of information in the menubar. Basically any script that can be executed on the terminal and has some kind of output can be used to display this output. | ||
This is how my BitBar output looks at the moment:</description> | ||
</item> | ||
<item> | ||
<title>LaMetric Firmware 1.7.5</title> | ||
<link>https://dfghj.de/lametric-firmware-1-7-5/</link> | ||
<pubDate>Tue, 31 Jan 2017 22:37:29 +0000</pubDate> | ||
<guid>https://dfghj.de/lametric-firmware-1-7-5/</guid> | ||
<description>A new firmware for the LaMetric Time is out – version 1.7.5 has some nice things to offer for those of us who would like to use the device in home automation (sadly the documentation is not yet updated). While this has been announced in the change log for 1.7.4, there have been some bugs and there are still one or two things that needs fixing, but that’s just minor stuff.</description> | ||
</item> | ||
</channel> | ||
</rss> | ||
<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Article on Alex' Blog</title><link>http://localhost:1313/categories/article/</link><description>Recent content in Article on Alex' Blog</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Fri, 10 Feb 2017 13:23:47 +0000</lastBuildDate><atom:link href="http://localhost:1313/categories/article/index.xml" rel="self" type="application/rss+xml"/><item><title>QuickFolders – a BitBar plugin</title><link>http://localhost:1313/posts/quickfolders-a-bitbar-plugin/</link><pubDate>Fri, 10 Feb 2017 13:23:47 +0000</pubDate><guid>http://localhost:1313/posts/quickfolders-a-bitbar-plugin/</guid><description><p>I’m a big fan of <!-- raw HTML omitted -->BitBar<!-- raw HTML omitted -->, an application that allows you to “Put anything in your Mac OS X menu bar” (macOS nowadays). People have already created more than 250 plugins which allow you to show plenty of information in the menubar. Basically any script that can be executed on the terminal and has some kind of output can be used to display this output.</p></description></item><item><title>LaMetric Firmware 1.7.5</title><link>http://localhost:1313/posts/lametric-firmware-1-7-5/</link><pubDate>Tue, 31 Jan 2017 22:37:29 +0000</pubDate><guid>http://localhost:1313/posts/lametric-firmware-1-7-5/</guid><description><p>A new firmware for the LaMetric Time is out – <a href="http://firmware.lametric.com">version 1.7.5</a> has some nice things to offer for those of us who would like to use the device in home automation (sadly the documentation is not yet updated). While this has been announced in the change log for 1.7.4, there have been some bugs and there are still one or two things that needs fixing, but that’s just minor stuff.</p></description></item></channel></rss> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,84 +1,7 @@ | ||
<!DOCTYPE html> | ||
<html><head lang="en"> | ||
<meta charset="utf-8" /> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"><title>Categories - Alex' Blog</title><meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<meta name="description" content="" /> | ||
<meta property="og:image" content=""/> | ||
<link rel="alternate" type="application/rss+xml" href="https://dfghj.de/categories/index.xml" title="Alex' Blog" /> | ||
<meta property="og:title" content="Categories" /> | ||
<meta property="og:description" content="" /> | ||
<meta property="og:type" content="website" /> | ||
<meta property="og:url" content="https://dfghj.de/categories/" /> | ||
|
||
<meta name="twitter:card" content="summary"/> | ||
<meta name="twitter:title" content="Categories"/> | ||
<meta name="twitter:description" content=""/> | ||
|
||
|
||
<link href="https://dfghj.de/css/fonts.2c2227b81b1970a03e760aa2e6121cd01f87c88586803cbb282aa224720a765f.css" rel="stylesheet"> | ||
|
||
|
||
|
||
<link rel="stylesheet" type="text/css" media="screen" href="https://dfghj.de/css/main.ac08a4c9714baa859217f92f051deb58df2938ec352b506df655005dcaf98cc0.css" /> | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<link rel="stylesheet" type="text/css" href="https://dfghj.de/css/carousel.7246d67ed223552bcaacc5e2e16718046d961485b18484de18ab08df89eb9988.css"> | ||
|
||
</head> | ||
<body> | ||
<div class="content"><header> | ||
<div class="main"> | ||
<a href="https://dfghj.de">Alex' Blog</a> | ||
</div> | ||
<nav> | ||
|
||
|
||
</nav> | ||
</header> | ||
|
||
<h1 class="page-title">All tags</h1> | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<div class="tag-cloud"> | ||
<ul class="tags"> | ||
|
||
|
||
|
||
<li><a style="font-size: 1rem;" href="https://dfghj.decategories/tutorial/">tutorial</a></li> | ||
|
||
|
||
|
||
<li><a style="font-size: 1rem;" href="https://dfghj.decategories/article/">article</a></li> | ||
|
||
|
||
|
||
<li><a style="font-size: 1rem;" href="https://dfghj.decategories/review/">review</a></li> | ||
|
||
</ul> | ||
</div> | ||
<footer> | ||
<div style="display:flex"></div> | ||
<div class="footer-info"> | ||
2023 <a | ||
href="https://github.com/athul/archie">Archie Theme</a> | Built with <a href="https://gohugo.io">Hugo</a> | ||
</div> | ||
</footer> | ||
|
||
|
||
</div> | ||
</body> | ||
</html> | ||
<!doctype html><html><head lang=en><script src="/livereload.js?mindelay=10&v=2&port=1313&path=livereload" data-no-instant defer></script><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><title>Categories - Alex' Blog</title><meta name=viewport content="width=device-width,initial-scale=1"> | ||
<meta name=description content><meta property="og:image" content><link rel=alternate type=application/rss+xml href=http://localhost:1313/categories/index.xml title="Alex' Blog"><meta property="og:url" content="http://localhost:1313/categories/"><meta property="og:site_name" content="Alex' Blog"><meta property="og:title" content="Categories"><meta property="og:locale" content="en_us"><meta property="og:type" content="website"><meta name=twitter:card content="summary"><meta name=twitter:title content="Categories"><script src=http://localhost:1313/js/feather.min.js></script><link href=http://localhost:1313/css/fonts.2c2227b81b1970a03e760aa2e6121cd01f87c88586803cbb282aa224720a765f.css rel=stylesheet><link rel=stylesheet type=text/css media=screen href=http://localhost:1313/css/main.5cebd7d4fb2b97856af8d32a6def16164fcf7d844e98e236fcb3559655020373.css><link id=darkModeStyle rel=stylesheet type=text/css href=http://localhost:1313/css/dark.d22e2a2879d933a4b781535fc4c4c716e9f9d35ea4986dd0cbabda82effc4bdd.css disabled><link rel=stylesheet type=text/css href=http://localhost:1313/css/carousel.7246d67ed223552bcaacc5e2e16718046d961485b18484de18ab08df89eb9988.css></head><body><div class=content><header><div class=main><a href=http://localhost:1313/>Alex' Blog</a></div><nav><a href=/>Home</a> | ||
<a href=/posts>All posts</a> | ||
<a href=/tags>Tags</a> | ||
| <span id=dark-mode-toggle onclick=toggleTheme()></span> | ||
<script src=http://localhost:1313/js/themetoggle.js></script></nav></header><h1 class=page-title>All tags</h1><div class=tag-cloud><ul class=tags><li><a style=font-size:1rem href=http://localhost:1313/categories/tutorial/>tutorial</a></li><li><a style=font-size:1rem href=http://localhost:1313/categories/article/>article</a></li><li><a style=font-size:1rem href=http://localhost:1313/categories/review/>review</a></li></ul></div><footer><div style=display:flex><a class=soc href=https://github.com/alex-ruehe rel=me title=GitHub><i data-feather=github></i></a> | ||
<a class=border></a></div><div class=footer-info>2024 <a href=https://github.com/athul/archie>Archie Theme</a> | Built with <a href=https://gohugo.io>Hugo</a></div></footer><script>feather.replace()</script></div></body></html> |
Oops, something went wrong.