First time here? Check out the FAQ!
1

What is the best way to set up Wing to work with ESRI Tools created with Python 2.7 or Python 3.x?

I want to be able to switch from one version of Python to another so that I can support both older scripts that were created to work with ArcGIS Desktop (Python 2.7) and to begin creating\supporting scripts written for ArcGIS Pro (Python 3.x).

I've seen documentation for "Projects", "Launch Configuration" and "Activated Environment". I am using Personal 10.0.8.0.

LayneSeely's avatar
11
LayneSeely
asked 2025-01-29 11:09:13 -0600
edit flag offensive 0 remove flag close merge delete

Comments

add a comment see more comments

2 Answers

0

You can set Python Executable in Project Properties, from the Project menu, to tell Wing which Python installation or environment to use. In general we recommend using one per project and use Projects > Recent to switch quickly as needed. With Launch Configurations you can use multiple envs in one project in various ways, like setting up different Python envs for different unit test files, but code analysis, error checking, etc, all only use the main env.

I don't have any info specific to ArcGIS but I know Wing is often used with that and from what I'm finding online I think it's just a question of setting up the Python env. Please let us know if you have other questions or this doesn't help.

Wingware Admin's avatar
268
Wingware Admin
answered 2025-01-30 07:18:33 -0600
edit flag offensive 0 remove flag delete link

Comments

add a comment see more comments
0

Thank you for the response. I have set up projects for Python Desktop & Python Pro - with each pointing to the appropriate executable. However, now I am getting the following error from a script called "os.py" when I open Wing:

File "C:\Program Files\Wing Personal 10\bin\x-wingide-python-shell:\2083789798880\1", line 29, in File "C:\Program Files\Wing Personal 10\bin\x-wingide-python-shell:\2083789798880\1", line 12, in File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib_collections_abc.py", line 774, in get return self[key] File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\os.py", line 676, in __getitem__ value = self._data[self.encodekey(key)] builtins.KeyError: 'PYTHONSTARTUP'

LayneSeely's avatar
11
LayneSeely
answered 2025-01-30 11:18:26 -0600
edit flag offensive 0 remove flag delete link

Comments

Is the above copy/pasted? Lib_collections_abc.py is almost certainly wrong and should be Lib\_collections_abc.py (this file is a part of Python) but I'm not sure where that wrong path is coming from. The official _collections_abc.py doesn't contain any reference to PYTHONSTARTUP and doesn't match what the above traceback seems to indicate so I'm not sure what is going on. Are you running something in the Python Shell or is this just appearing when you start Wing?

Wingware Admin's avatar Wingware Admin (2025-01-30 13:36:18 -0600) edit

I had copied and pasted it directly from the Exceptions window. I also noticed that it was still finding Python 2.7 in the source python env. I changed it to be "Command Line" to the appropriate Python 3 install.

It still fails on start up of Wing.

File "C:\Program Files\Wing Personal 10\bin\x-wingide-python-shell:\1889257014688\1", line 29, in <prompt>
File "C:\Program Files\Wing Personal 10\bin\x-wingide-python-shell:\1889257014688\1", line 12, in <prompt>
File "c:\program files\arcgis\pro\bin\python\envs\arcgispro-py3\lib\_collections_abc.py", line 774, in get
  return self[key]
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\os.py", line 676, in __getitem__
  value = self._data[self.encodekey(key)]

builtins.KeyError: 'PYTHONSTARTUP'

Interesting --> when I pasted it it looks right but when I hit save then it looks like "lib_collections"

LayneSeely's avatar LayneSeely (2025-01-30 14:42:04 -0600) edit

Oh, actually now that I look at the code more carefully I think the above is a printing of a traceback that is happening but handled. The code in _collections_abc.py is in the implementation of mapping's get() method, which tries to do self[key] and if that fails then uses the given default. It should hit that exception but normally it would be silent and execution will continue. The code looks like this:

try:
    return self[key]
except KeyError:
    return default

I suspect that you can still use the Python Shell and the printing of that exception can be ignored. It might be due to having changed the Debugger > Exceptions > Report Exceptions preference in Wing to Always Immediately. If so, change that back to the default When Printed.

If that doesn't help you could try turning on the Debugger > Advanced > Use Legacy Tracer Core with Python 3.12+ preference ... (more)

Wingware Admin's avatar Wingware Admin (2025-01-30 15:57:30 -0600) edit

That did it !!! It was indeed set to "Always Immediately".

LayneSeely's avatar LayneSeely (2025-01-30 17:26:46 -0600) edit

Great, thanks for letting us know what it was!

Wingware Admin's avatar Wingware Admin (2025-01-30 17:32:56 -0600) edit
add a comment see more comments

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss.

Add Answer