First time here? Check out the FAQ!
1

OS Command issue

Wing Pro, 9.1.1.4, Win 10.
I'm trying to create an OS command that I've used in other projects and it isn't using the right Python version nor finding ssort (it runs fine in a command window in the activated venv). I'm using 3.11 (also have 3.9 & 3.10 installed).

image description image description image description

The project was setup to use an existing venv with 3.11. The larger project is a Django project but I've also created a project in the same venv that is not configured as a Django project since I was having trouble figuring out how to run a script/file without using the Django config; just as a plain Python file. This is the plain project where I'm having a problem:

image description image description

I added a print(sys.path) to the bottom of a Python file and ran it in Wing (F5):

['C:\GitRepo\ee_web_django\ee_web\ee_web\components', 'C:\Users\EricE\AppData\Local\Programs\Python\Python311\python311.zip', 'C:\Users\EricE\AppData\Local\Programs\Python\Python311\DLLs', 'C:\Users\EricE\AppData\Local\Programs\Python\Python311\Lib', 'C:\Users\EricE\AppData\Local\Programs\Python\Python311', 'C:\GitRepo\ee_web_django\venv', 'C:\GitRepo\ee_web_django\venv\Lib\site-packages']

RunDeep's avatar
68
RunDeep
asked 2023-07-28 14:49:25 -0500
Wingware Support's avatar
4.1k
Wingware Support
updated 2023-12-07 08:23:42 -0500
edit flag offensive 0 remove flag close merge delete

Comments

Is the Python 3.11 in C:\Users\EricE\AppData\Local\Programs\Python\Python311 the one that has ssort installed into it? Try to see if changing the OS Command to the following prints the right Python:

${WING:PYTHON} -c "import sys; print(sys.executable)"

I suspect it'll be the Python 3.9 but want to check this since I wasn't able to replicate this as a bug here and it's odd that your sys.path that you printed does seem to be for the right Python.

Also take a look to be sure that you get the right sys.executable from the Wing Python Shell and also compare that to what's shown in the Source > Show Python Environment dialog. Normally, they should all be the same and match the venv you've set in Project Properties.

One idea is to get the sys.executable from the correct Python and set the Python Executable in Project Properties to Command Line and then use the full ... (more)

Wingware Support's avatar Wingware Support (2023-07-28 15:05:33 -0500) edit
add a comment see more comments

1 Answer

0

ssort is installed in a venv:

C:\GitRepo\ee_web_django\venv\Lib\site-packages\ssort

${WING:PYTHON} -c "import sys; print(sys.executable)" gave me:

C:\Users\EricE\AppData\Local\Programs\Python\Python39\python.exe

From the Python Shell:

'sys.path

['', 'C:\Users\EricE\AppData\Local\Programs\Python\Python311\python311.zip', 'C:\Users\EricE\AppData\Local\Programs\Python\Python311\DLLs', 'C:\Users\EricE\AppData\Local\Programs\Python\Python311\Lib', 'C:\Users\EricE\AppData\Local\Programs\Python\Python311', 'C:\GitRepo\ee_web_django\venv', 'C:\GitRepo\ee_web_django\venv\Lib\site-packages']

sys.version

('3.11.4 (tags/v3.11.4:d2340ef, Jun 7 2023, 05:45:37) [MSC v.1934 64 bit ' '(AMD64)]')'

image description

Per your last suggestion, switching to Command Line in Project Properties and pasting in:

C:\GitRepo\ee_web_django\venv\Scripts\python.exe

got ssort running (and isort). I actually used this time to look at ruff and added it as an OS Command, I think I found a new and better tool...

RunDeep's avatar
68
RunDeep
answered 2023-07-28 18:59:33 -0500
edit flag offensive 0 remove flag delete link

Comments

Glad that got it working. Since the Python Environment dialog says "" I suspect there was some issue in activating the env. If you want to pursue it, submitting a bug report from Wing's help menu might show us what failed.

Ruff does look pretty promising. We've added support for it as an external checker in Wing Pro's Code Warnings tool in Wing 10 (not yet released).

Wingware Support's avatar Wingware Support (2023-07-28 22:03:22 -0500) 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