Answer a question

I have a Windows machine and I'm trying to use WSL that I can use Linux to complete a learning project by Corey Schafer on Django development. (All had been well until I had to use Gunicorn which works best on Linux from my reading)

source 

Windows VS Code Terminal (Running the right python executable)

(Corey Schafer - Django Framework) PS C:\Users\this_user\OneDrive - CUT\Learning\Python\Corey 
Schafer - Django Framework> python
Python 3.7.4 (tags/v3.7.4:e09359112e, Jul  8 2019, 19:29:22) [MSC v.1916 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.executable
'C:\\Users\\this_user\\.virtualenvs\\Corey_Schafer_-_Django_Framework-jrC3nBNH\\Scripts\\python.exe'

WSL (Ubuntu) on VS Code Terminal (Not the right python executable. Also showing my PATH variable with the path to virtual environments added in)

    (Corey Schafer - Django Framework) this_user_name@this_PC:/mnt/c/Users/this_user/.virtualenvs/Corey_Schafer_-_Django_Framework-jrC3nBNH/Scripts$ python
    Python 3.7.4 (default, Dec 27 2019, 13:49:49)
    [GCC 7.4.0] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import sys
    >>> sys.executable
    '/usr/local/bin/python3.7'
    (Corey Schafer - Django Framework) this_user_name@this_PC:/mnt/c/Users/this_user/.virtualenvs/Corey_Schafer_-_Django_Framework-jrC3nBNH/Scripts$ echo $PATH
    /C/Users/this_user/.virtualenvs/Corey_Schafer_-_Django_Framework-rC3nBNH/Scripts:
    /mnt/c/Users/this_user/.virtualenvs:/home/this_user_name/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:
    /sbin:/bin:/usr/games:/usr/local/games:/mnt/c/WINDOWS/system32:/mnt/c/WINDOWS:/mnt/c/WINDOWS/System32/Wbem:/mnt/c/WINDOWS/System32/WindowsPowerShell/v1.0/:
    /mnt/c/WINDOWS/System32/OpenSSH/:/mnt/c/Program Files/Git/cmd:/mnt/c/Program Files/PostgreSQL/12/bin:/mnt/c/Users/this_user/.virtualenvs:
    /mnt/c/Users/this_user/.virtualenvs/Corey_Schafer_-_Django_Framework-rC3nBNH/Scripts:
    /mnt/c/Users/this_user/AppData/Local/Microsoft/WindowsApps:/mnt/c/Users/this_user/AppData/Local/GitHubDesktop/bin:
    /mnt/c/Users/this_user/AppData/Local/Programs/Python/Python37-32:/mnt/c/Users/this_user/AppData/Local/Programs/Python/Python37-32/Scripts:
    /mnt/c/Users/this_user/AppData/Local/Programs/Microsoft VS Code/bin:/mnt/c/Program Files/heroku/bin:/snap/bin:
    /mnt/c/Users/this_user/.virtualenvs/Corey_Schafer_-_Django_Framework-jrC3nBNH/Scripts$

Settings.json file for my workspace folder (I recognize the pythonpath is for the Windows directory, but not sure what to put in that it can be recognised both on Windows and Linux. Tried to put the right path from the Linux directory and it still did not work)

    {
        "python.pythonPath": "C:\\Users\\this_user\\.virtualenvs\\Corey_Schafer_-_Django_Framework-jrC3nBNH\\Scripts\\python.exe",
        "python.autoComplete.extraPaths": [
            "./django_project"
        ],
    }

My .profile file

    # ~/.profile: executed by the command interpreter for login shells.
    # This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
    # exists.
    # see /usr/share/doc/bash/examples/startup-files for examples.
    # the files are located in the bash-doc package.

    # the default umask is set in /etc/profile; for setting the umask
    # for ssh logins, install and configure the libpam-umask package.
    #umask 022

    # if running bash
    if [ -n "$BASH_VERSION" ]; then
        # include .bashrc if it exists
        if [ -f "$HOME/.bashrc" ]; then
        . "$HOME/.bashrc"
        fi
    fi

    # set PATH so it includes user's private bin if it exists
    if [ -d "$HOME/bin" ] ; then
        PATH="$HOME/bin:$PATH"
    fi

    # set PATH so it includes user's private bin if it exists
    if [ -d "$HOME/.local/bin" ] ; then
        PATH="$HOME/.local/bin:$PATH"
    fi


    #Adding path to virtual enviroments
    PATH="/mnt/c/Users/this_user/.virtualenvs:$PATH"
    export PATH

From the image below, the interpeter from my virtual environment is not among the options to be selected (There's also other interpreters in the same .virtualenv folder that I cannot see here that I can see on Windows). I also get a warning that a pipfile is recognised but a path to the pipenv activation is not found, again a problem with the path it seems (The "" is because I was trying to put the path to the 'path to pipenv' setting and at that point I left it blank.)

Image of running WSL in VS Code with error messages

I am new to Linux and relatively new to VS Code. Appreciate any help offered.

Answers

pipenv run pip freeze > requirement.txt

It works well as the 2 environments don't detect each other as I switch between Windows and WSL Ubuntu (as far as I can see) because of the different architectures of the python.exe programs. Glad I've learned something through this!