Showing posts with label virtualenv. Show all posts
Showing posts with label virtualenv. Show all posts

Wednesday, April 10, 2019

Troubleshooting Cmder Terminal in Visual Studio Code

If you didn't know, you can customize the terminal for VScode. In my case, I wanted to use cmder because Windows terminals suck; both of them cmd and powershell.

Fortunately, cmder has a guide for integrating it to VScode.

The interesting thing is when I tried using it with my Python workflow which includes virtual environements via Pipenv and I ran into a couple of problems.

Problem #1 Missing posh-git

Symptom Spits out a warning telling you that you are missing posh-git - 'Install-Module posh-git' and restart cmder"

Fix #1 Run from the admin level PShell:  Install-Module posh-git

You might also get a error saying it might have an overlap with some other extension like say 'TabExpansion'.

Fix #2 Either run Fix#1 with the -AllowClobber or -Force option OR run it with a -Scope option: Install-Module posh-git -Scope CurrentUser

----

Problem #2 FunctionNotWritable (Cannot write to function prompt..)

Symptom Spits out the error; Also notice that your terminal prompt isn't prefixed by the activated virtual environment. Only happens when your doing Python with virtual environments.

Fix #1 Remove or comment out the -Options ReadOnly option on the cmder profile.ps1. Details here.


Wednesday, July 25, 2018

Pyenv folder (.venv) with Pipenv

Pipenv, by default will use your virtualenv folder location if you set that environment variable - which probably be a .virtualenv or .env folder in your home directory.

But sometimes you would like to have the virtualenv folder within the project folder - ie. project/.venv No sweat, pipenv supports this workflow if set the PIPENV_VENV_IN_PROJECT environment variable.

For Macs: $ export PIPENV_VENV_IN_PROJECT=1

For Windows: > set PIPENV_VENV_IN_PROJECT=1

Do note that in Windows, you can also use setx.

Then we can run either a: pipenv install or pipenv --three to get started.




Wednesday, August 3, 2016

Tidbits on Python's virtualenv

Python being a mess that it is - *cough* Python 2 vs 3 *cough* - has a thing for virtual dev environments.

Virtual dev enviroments or virtualenv solves the mess by creating isolated dev environments. Each environment then can have it's own Python and lib versions, dependencies and even permissions and settings. Virtualenv is complimented by virtualenvwrapper.

This is all well and good, unfortunately, virtualenv + wrapper are terminal (command line) driven and I often forget the basic commands. Hence, this blog post:

Basic assumption here is that you've setup and configured virtualenv with virtualenvwrapper.

1. Make a new virtual environment with a specific version of Python: use the -p flag

mkvirutalenv -p [path-to-python] [project name]

example: mkvirtualenv -p /usr/bin/python project1

2. List all existing virtual environments; workon command without arguments also works

lsvirtualenv -b

-b flag = brief mode, disables verbose output

3. Delete or remove an existing virtual environment; only deletes environments found in the WORKON_HOME path

rmvirtualenv [env_name]

Virtual environment must be deactivated before removing.

4. Deactivate current active virtual environment

deactivate

Also:

- Command ref for virtualenvwrapper
- Ref for virtualenv