Abstract Planes

More than a month ago, I discovered Abstract Planes. I’ve spent almost every day with them ever since. Like many things in life, Abstract Planes were discovered by accident. I was trying to create…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Virtualenv for Python projects

Virtualenv is a tool that lets you create an isolated Python environment for your project. It creates am environment that has its own installation directories, that doesn’t share dependencies with other virtualenv environments. You can even configure what version of Python you want to use for each individual environment. It’s very much recommended to use virtualenv when dealing with Python applications.

To install virtualenv run:

If you have a project in a directory called my-project you can set up virtualenv for that project by running:

If you want your virtualenv to also inherit globally installed packages run:

These commands create a venv/ directory in your project where all dependencies are installed. You need to activate it first though (in every terminal instance where you are working on your project):

You should see a (venv) appear at the beginning of your terminal prompt indicating that you are working inside the virtualenv. Now when you install something like this:

It will get installed in the venv/ folder, and not conflict with other projects.

To leave the virtual environment run:

Important: Remember to add venv to your project's .gitignore file so you don't include all of that in your source code.

It is preferable to install big packages (like Numpy), or packages you always use (like IPython) globally. All the rest can be installed in a virtualenv.

Add a comment

Related posts:

Dari Orang Jepang ke Norma Sosial

Itu parafrasa. Kurang lebih itu yang aku tangkap dari celetukan ibuku tadi siang. Sepanjang perjalanan aku diam saja. Tapi otakku sebenarnya sibuk memikirkan ide tadi. “Hah, menarik juga!” Aku pernah…

My Body is a Party

Eating the food I give is like chewing glass. Their gums bleed. Water isn't enough to make the journey down the throat any easier. Like a woman with an overdue pregnancy awaiting release, all parts…

The One Thing You Need to Succeed at Freelancing? Financial Security.

To this day I still recall an intense feeling of anxiety on a bus trip home. I realised in that moment I had almost no money in my bank account. That was the only time I’ve ever felt physically sick…