2

Running the latest VsCode under Windows 10, I have installed wxPython from a terminal window into the Python 3.6.3 standard environment (the one it mentions when I ask python -V).

Within VsCode, provided I select that environment (Python 3.6.3 32-bit), my application runs fine.

However, if I switch to either of my other two environments, Python 3.6.6 64-bit or Python 3.7.2 32-bit, the import wx fails, presumably because I haven't pip install-ed wxPython into those environments.

How do I do this, pip install a package into a specific environment configured in VsCode?

I see that, when VsCode runs my application, it does something like:

cd 'c:\Users\Pax\Documents\pysrc';
${env:PYTHONIOENCODING}='UTF-8'; ${env:PYTHONUNBUFFERED}='1'; &
    'C:\Users\Pax\AppData\Local\Programs\Python\Python36-32\python.exe'
    'c:\Users\Pax\.vscode\extensions\blah\blah\ptvsd_launcher.py'
    '--default' '--client' '--host' 'localhost' '--port' '53664'
    '-m' 'myapp.py'

Do I need to do something similarly opaque when running pip?

4
  • How do you manage your environments? Using conda or directly create it using VsCode? Commented Mar 4, 2019 at 1:46
  • @Sraw, I don't (knowingly) use Conda. I'm pretty sure I had at least one environment installed when I installed VsCode, though it could have been more. The other two may have been added later, and picked up by VsCode. Commented Mar 4, 2019 at 2:15
  • Well as I don't know how do you organize your environments, it is difficult to give an exact solution. There is a simplest one: If you can execute those two python environments no matter through the built-in terminal in VsCode or normal terminal, you should be able to install wxPython into corresponding environment by python -m pip install wxPython. Commented Mar 4, 2019 at 2:22
  • @Sraw, thanks heaps for your help, I managed to find a solution before I got a chance to try yours out, by running the specific pip for the environment. It appears from testing that running the specific python to run the specific pip also works so, if you'd like to post that as an answer, it's worth some rep. Commented Mar 4, 2019 at 2:32

2 Answers 2

1

Yes, you have to install it into each Python environment where you want to use it.

Assuming you're using a standard setup, this is probably as simple as:

C:\Users\Pax\AppData\Local\Programs\Python\Python37-32\Scripts\pip.exe install wxpython

This will pip install wxpython into the specific environment (Python 3.7 in this case) and allow you to use it from within the Python code running inside VsCode.

Sign up to request clarification or add additional context in comments.

Comments

0

I simply had to use pip3 instead of pip in my Terminal in Linux Mint 19.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.