65

I'm collaborating with some fellow students to build a python app, and was hoping to use the 'training wheels' of Visual Studio intelli-sense. They use python on mac and linux, so ideally our source control repo would consist of just *.py source files that we wrote, and a requirements.txt export of pip dependancies (using the pip freeze method).

I would love to be able to create a new Visual Studio project, then be able to run the following commands (for instance) within that project:

pip install boto
pip install fabric
pip install cuisine
pip freeze > requirements.txt

And after that, be able to write some code that references these libraries and be able to run it from within Visual Studio.

Is there any way to do this? Is Python within Visual Studio even able to handle modules in the format they are available within pip, or do all python libraries used in VS have to have been pre-compiled for Windows?

6 Answers 6

144

Yep! Go to Tools -> Python Tools -> Python Environments.

This will open a new pane where you can select pip (VS 2015) or Packages (VS 2017) from the menu (it will say Overview by default) and then you can enter your module and double click to install.

enter image description here

Some packages have complex dependencies, and you might need to install them manually from these links:

8
  • 3
    This is the best solution by far, and should be the accepted answer. Oct 23, 2015 at 23:19
  • 1
    Excellent, i was hoping VS would do this, and its does ! (VS 2015 Community Edition as well). Dec 15, 2015 at 18:43
  • 1
    I assumed it would be here too. Make sure this panel is big enough or it will hide the package management. May 19, 2016 at 11:37
  • 1
    @cal97g When the panel is smaller, you just have to change the dropdown menu from "Overview" to "pip". I just expanded it in the picture to show it all at once. May 20, 2016 at 14:53
  • 3
    I tried this in VS2017 and it now says "Packages" rather than pip Aug 24, 2017 at 21:45
9

On VS 2017, switch to the "solution explorer" and right click as indicated:

enter image description here

7

Yes you can, here is a simple guide taken from here https://zignar.net/2012/06/17/install-python-on-windows/

Before you can install Pip, you'll need setuptools or distribute. If you're using Python3, you must use distribute as setuptools doesn't support Python 3.x

To install distribute download the setup file here https://pypi.python.org/pypi/distribute/0.6.27 and invoke it using python.

python.exe C:\Path\to\distribute_setup.py

Now that distribute is installed, Pip can also be installed. Download get-pip.py here https://raw.github.com/pypa/pip/master/contrib/get-pip.py and invoke it in the same way you invoked distribute_setup:

python.exe c:\Path\to\get-pip.py

After that Pip is installed. But you might want to add C:\Python32\Scripts to the Path Systemvariable too (see step 1). So you can execute pip.exe from any location.

2
  • Also, i've used this page which has a lot of python extensions packages as binaries for easy install : lfd.uci.edu/~gohlke/pythonlibs
    – Axel
    Mar 3, 2013 at 13:16
  • Didn't know where to start. I'm a noob and need a step by step walkthrough on windows. No help as I didn't know what to use to install these or where to go...
    – Exzile
    Jul 6, 2014 at 20:09
7

From the mention of Visual Studio, it sounds like you're using Python Tools for Visual Studio. If so, then support for pip, easy_install and virtualenv is one of the new features in PTVS 2.0 beta - get it and give it a try. Once you add an interpreter reference to your project, you'll find commands to install a package in context menu for that interpreter in Solution Explorer.

This way, you also do not have to set up pip yourself, since PTVS will do it for you the first time you try to install a package.

5

When you install Python support with Visual Studio, the PIP executable can be found in C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\Scripts If it isnt there, type the following at a command prompt to find out Pythons install location py --location Then either add the location to path, or run pip with the full path from powershell . "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\Scripts\pip.exe" install pillow

1

and you can set your path to pip like this:

Open cmd prompt

Run set PATH="C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64"

1
  • 4
    this will remove all other directories from PATH, instead you should append the directory to PATH variable `set PATH=%PATH%;C:\your\path\here` Jul 4, 2019 at 16:12

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.