-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Description
First, thank you the existing documentation!! I would like more detailed information for creating a portable VS Code environment with a python virtual environment. If something like this exists somewhere I would be ecstatic to read it, but can you also add a link from the VS Code Portable Mod page to it? Hopefully, I'm including all the relevant info and apologies for any confusing wording ahead. I have some mental fog due to chronic fatigue/arthritis.
First steps: I first posted to Stackoverflow and got one person trying to help, my stackoverlow post. They provided links to information I had already read but didn't find enough new info to help: Global, Virtual, and Conda Environments and Getting Started>Settings.
Other pages I read:
-VS Code Setup>Windows,
-VS Code Portable Mode. Side Note: RFE "Portable Mode" is misleading since the info provided is merely for running from a different drive of a single machine. For it to be a portable mode, it needs to accomodate a variable mount point on any machine. For example, I thought using ${workspaceFolder} in the VS Code settings.json files would stand in for a variable drive but it didn't seem to work.
-VS Code Python Environments
Hardware setup: Windows 10 OS. I am working with a HP laptop workstation and a small SurfaceGo that I switch back and forth on for day and night time work. On the HP laptop, the USB mounts to the F:\ drive with the user name "Dev". On the SurfaceGo the USB mounts to the D:\ drive with the user name "megha".
Software setup: Initially setup everything from the HP workstation. "VSCode-win32-x64-1.49.0.zip" was unzipped to F:\Programs\Microsoft\VS Code. Also did a custom install of "python-3.8.6rc1-amd64.exe" to F:\Python\Python38; checked marked "Add to Path". My code development is located at F:\MyProject.
Cleanup: I removed C:\Users\Dev\.virtualenvs\, C:\Users\Dev\.vscode\, C:\Users\Dev\AppData\Local\Programs\Microsoft VS Code, C:\Users\Dev\AppData\Roaming\Code, F:\Programs\Microsoft VS Code\data\user-data\User\settings.json, F:\MyProject\.venv\, F:\MyProject\.vscode\, F:\MyProject\rr.code-workspace.
Usual VS Code/Python environment setup:
from powershell.
pipenv automatically installs to :\Users<user>.virtualenvs even after the venv command. Therefore I've been using py -m pip install -t ...
> cd F:\MyProject
> py -m venv --system-site-packages .venvHP
> py -m pip install -t .\.venvHP\Lib\site-packages\ -r .\requirements.txt
> py -m pip install -r requirements
> & "F:\Programs\Microsoft VS Code\code.exe" .
from VS Code
File > Open Folder
File > Save Workspace as (rr.code-workspace)
Termial > New Terminal
Ctrl+Shift+P to add new .venv\Scripts\python.exe interpreter
I can get VS Code/Python venv set up and working for one machine but after trying to make accommodations in the settings.json files (MyProject\.vscode, Microsoft VS Code\data\user-data\User) by changing F:\MyProject to ${workspaceFolder} I got stuck. I'm not sure where else changes need to be made.
Goal: I would like a way to set up my environment to actually be Portable between machines. I would prefer no VS Code settings show up in any of my ~\<user>\ folders on the hard drives. Is it possible to do this?
Side Note: RFE If it is possible to for VS Code to work with a variable USB mount point, can there be instructions for addressing that? Is there a way to do it without having to download too much to the hard drive? There are probably more places than settings.json that need adjustment, but VS Code Portable Mode page doesn't discuss it or have links to relevant info.
It would also be useful if the docs were written in a more sequential fashion rather than scattered bits and pieces.
Unanswered questions:
- Do I need to create individual python virtual environments for each separate computer?
- Do I need separate
.vscode\settings.jsonfiles for each environment? And if so how exactly do I activate each one within VS Code. How does that look directory-wise? See the Directory Maps below. - While I can run
<usbdrive>:\Python\Python38\python.exefrom both machines, it requires using "python-3.8.6rc1-amd64.exe" to do a full custom install to the USB for each machine, I assume in order to get all the registry and pathing setup for the most part. Does that sound correct? Does this cause any problems for VS Code?
Directory Map 1
-MyProject\
-.venvHP\
-.venvGo\
-.vscode\
settings.json
settings-HP.json ***assume I would copy this to settings.json when using HP***
settings-Go.json ***assume I would copy this to settings.json when using SurfaceGo***
Directory Map 2 the method below would mean copying my programming code between them. This way doesn't make sense to me, so pretty sure I'm off track here.
-MyProjectHP\
.venv\
.vscode\
-MyProjectGo\
.venv\
.vscode\