惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

WordPress大学
WordPress大学
阮一峰的网络日志
阮一峰的网络日志
Jina AI
Jina AI
博客园 - Franky
U
Unit 42
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
宝玉的分享
宝玉的分享
B
Blog RSS Feed
雷峰网
雷峰网
D
DataBreaches.Net
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
I
InfoQ
美团技术团队
云风的 BLOG
云风的 BLOG
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Martin Fowler
Martin Fowler
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
大猫的无限游戏
大猫的无限游戏
G
Google Developers Blog
T
Tailwind CSS Blog
P
Proofpoint News Feed
The GitHub Blog
The GitHub Blog
月光博客
月光博客
Engineering at Meta
Engineering at Meta

Nik Ogura

The Digital Plumber | Nik Ogura Chasing Nines | Nik Ogura Writing for Generation Ships | Nik Ogura nikogura.com Load-Bearing Humans | Nik Ogura Your Hiring Pipeline Has the Same Bug as Your Deploy Pipeline | Nik Ogura Nice People Who Give Us Money | Nik Ogura Gambling on Failure | Nik Ogura DDCRI: Declarative, Deterministic, Continuously Reconciling Infrastructure | Nik Ogura Stop Holding Out for a Hero | Nik Ogura Don't Paint Yourself Into a Corner | Nik Ogura Most Infrastructure as Code Is Broken — and Reconciliation Is Only Half the Reason | Nik Ogura Continuous Acceptance Tests | Nik Ogura There's More Than One Way to Get Observability Right | Nik Ogura Put Dex In Front of Google OAuth | Nik Ogura Incident Management | Nik Ogura C-Style Thinking vs Go-Style Thinking | Nik Ogura 'Can' vs 'Does' | Nik Ogura Control Repositories | Nik Ogura Trunk-Based Development | Nik Ogura Web3 Is Just Infrastructure With a Hoodie | Nik Ogura "Design Me a Highly Resilient Database" | Nik Ogura Security Is Infrastructure | Nik Ogura Metrics, Logs, Traces, and Events: What's Actually Different | Nik Ogura Distributed Tracing: A Practical Guide | Nik Ogura Prometheus and OpenTelemetry: How They Fit Together | Nik Ogura Puppets and Octopi: Why Top-Down Orchestration Hits a Wall | Nik Ogura The Best Dog Trainer in the World - Or Why Getting Better Isn't Helping | Nik Ogura FluxCD vs ArgoCD: Architectural Comparison | Nik Ogura GitOps | Nik Ogura
LocalEnv | Nik Ogura
2017-12-09 · via Nik Ogura

An IDE is nice, but occasionally it’s useful to shell out to the command line. The problem is, without extra care and feeding, what’s going on in your IDE with it’s plugins and menus might not be accurately represented in your command line environment, leading to very different and confusing results.

Python virtualenvs are a great example of a case where it’s useful to link your IDE and your terminal window. To link them, try the following:

Inside the root of your project, craft a file like ‘.localenv’ pointing at where you put the virtualenv. The file name doesn’t matter, it just has to contain the path where you decided to put your virtualenvs

    source <VIRTUALENV_DIR>/<PROJECT>/bin/activate
    
    

Then in your ~/.bash_profile put this:

    if [ -e "$(pwd)/.localenv" ]; then
      source $(pwd)/.localenv
    fi

Voila! When you open a terminal window in IntelliJ, it automatically will source the virtualenv and any python commands will use that python, and those libraries. Your normal, external terminal windows will still be pointing at your defaults, but the terminal window in any given IntelliJ project will automatically open to that project’s virtualenv. Neat huh?

Interestingly enough, this trick works well for other languages and tools. Works great for LaTeX for example, if you’re into that.