Visual Studio Code: Difference between revisions
Brian Wilson (talk | contribs) mNo edit summary |
Brian Wilson (talk | contribs) |
||
Line 12: | Line 12: | ||
Here is a doc telling [https://code.visualstudio.com/docs/python/environments#_where-the-extension-looks-for-environments where it looks]. | Here is a doc telling [https://code.visualstudio.com/docs/python/environments#_where-the-extension-looks-for-environments where it looks]. | ||
==== Work around the problem ==== | ==== 1 Work around the problem ==== | ||
On [[Murre]] this was a problem. It's seeing non-existent ArcMap pythons and the emacs python but not the one WindowsApps installed. | On [[Murre]] this was a problem. It's seeing non-existent ArcMap pythons and the emacs python but not the one WindowsApps installed. | ||
Line 21: | Line 21: | ||
python3 -m venv .venv | python3 -m venv .venv | ||
==== | ==== 2 Better way, adjust settings ==== | ||
This is a better solution, first put the commonly used variables into your user settings, | This is a better solution, first put the commonly used variables into your user settings, |
Revision as of 18:46, 30 March 2020
where does it ever end? Komodo -> Microsoft Visual Studio -> Atom -> Visual Studio Code
I am now learning Visual Studio Code
I am currently using VSC to edit Python to create Geoprocessing scripts that I can run in Docker containers.
Settings
It's not finding Python!!
Here is a doc telling where it looks.
1 Work around the problem
On Murre this was a problem. It's seeing non-existent ArcMap pythons and the emacs python but not the one WindowsApps installed. But the Powershell it launches can see it. So in the Powershell I created a virtual environment and told it to use that.
This works because it will search the current workspace.
python3 -m venv .venv
2 Better way, adjust settings
This is a better solution, first put the commonly used variables into your user settings, File -> Preferences -> Settings -> User -> Extensions -> Python
This assumes you are using ArcGIS Pro.
Python: Conda path: "C:/Program Files/ArcGIS/Pro/bin/Python/Scripts/conda.exe" Python: Venv folders: "AppData/Local/ESRI/conda/envs"
Reload VSCode. Intellisense should work for you now too.
Now when you select a Python version, the right ones should appear. Make sure you pick the right environment (for me I named it "arcgispro-py3-vscode")
ESRI .PYT files are not treated as Python
I put this in my global settings.json file (F1 File:Associations)
"files.associations": {"*.pyt": "python"}
Remote development
I've now tried this tutorial and learned it works. Python in a Container I got a simple Flask app running and then switched to running even simpler Python scripts in the container.
When I needed to add volume support I discovered this page: VS Code Remote Development It explains the Remote Development extension pack.
- I can use Remote - SSH to treat a remote machine (say, Bellman) as the host for a remote project. (* As recommended by John Sullivan.)
- I can use Remote - Containers to treat a Docker container as the host.
- I can use Remote - WSL too but I don't use Windows Subsystem for Linux currently.
Docker containers
I can keep the code on the local file system or in the container.
My first tests I used the Dockerfile to load my code into the image. It worked fine.
More options:
- clone from github into a running container
- keep code in a volume mounted on the container
Using a volume seems to make the most sense to me. In that setting I can still easily use command line git.
There is a sample based on python, it starts a Debian container and puts a Bash prompt into a Terminal window. It connects when you do F5. Your code is accessible on the local filesystem and in the mounted volume in the container.
git clone https://github.com/Microsoft/vscode-remote-try-python