First time here? Check out the FAQ!
2

How do I identify the executable for a virtual environment and use this in Wing?

After creating and configuring a Python environment from the command line, e.g., using conda, how would I use this environment in Wing? 

Steven C. Howell's avatar
56
Steven C. Howell
asked 2017-03-03 12:16:00 -0600
Wingware Support's avatar
4.2k
Wingware Support
updated 2019-04-30 08:18:26 -0600
edit flag offensive 0 remove flag close merge delete

Comments

add a comment see more comments

3 Answers

2

As of Wing 7.2, you can set the Python Executable in Project Properties to "Activated Env" and enter the command that activates the environment.

In all versions of Wing you can instead set Python Executable to the virtualenv's Python, which you can find as follows:

  1. Run the interpreter for your virtual environment outside of Wing.

  2. From that interpreter, you can identify the executable for the environment by running the commands: 

    import sys print(sys.executable)

3. From Wing, open the Project Properties dialog.

  1. Set the Python Executable to be the output from the sys.executable command.
Steven C. Howell's avatar
56
Steven C. Howell
answered 2017-03-03 12:20:00 -0600
Wingware Support's avatar
4.2k
Wingware Support
updated 2020-01-22 20:00:32 -0600
edit flag offensive 0 remove flag delete link

Comments

Note that in Wing 101 there are no Project Properties so this is set instead in the Configure Python dialog, from the Edit menu.

Wingware Support's avatar Wingware Support (2017-03-03 12:52:00 -0600) edit
add a comment see more comments
1

One thing to note is if you switch active projects and switch from a 2.7 project to a 3.3 project the python shell does not automatically switch from 2.7 to 3.3, you have to manually ask it to restart the shell - so if you have not done that and you check the shell to see the Python version it might be wrong.

Jeffrey Vahue's avatar
23
Jeffrey Vahue
answered 2017-03-09 13:57:00 -0600
edit flag offensive 0 remove flag delete link

Comments

But also note that in Wing 7 it will now auto-restart the shell when you switch projects. This can be disabled from the Python Shell's Options menu.

Wingware Support's avatar Wingware Support (2019-04-10 06:29:54 -0600) edit
add a comment see more comments
1

What about working with a remote host configuration, via SSH?

import sys; print(sys.executable)

gives me

/home/ichux/wingpro/venv-django2.2/bin/python

But the Python shell that is connected by SSH gives me

/usr/bin/python

I basically want to use the one that is from the virtualenv. How do I go about it? Please note that I tried setting it as instructed above but it did not work.

chukwudi.nwachukwu's avatar
51
chukwudi.nwachukwu
answered 2019-04-09 10:48:52 -0600
Wingware Support's avatar
4.2k
Wingware Support
updated 2019-04-10 06:27:11 -0600
edit flag offensive 0 remove flag delete link

Comments

If you are using a remote host from within Wing, you'd enter /home/ichux/wingpro/venv-django2.2/bin/python for the Python Executable in the remote host configuration

Wingware Support's avatar Wingware Support (2019-04-09 13:35:53 -0600) edit

It worked! Thanks so much. I had initially tried it but it failed for reasons I can't explain.

chukwudi.nwachukwu's avatar chukwudi.nwachukwu (2019-04-10 05:03:09 -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