Using Anaconda and PTVS

Visual Studio is my favorite IDE by far, and when I heard that Python Tools for Visual Studio (PTVS) upgraded to v2.0 beta I was excited to test out the new features. However, I just started using Anaconda as my main Python distro which leads to problems with PTVS detecting any environments created using Anaconda.

Note that I'm not talking about virtualenvs, but rather Aanaconda's environments

I was able to get a Python 3.3 environment installed and running on Visual Studio, and here's what I did.

Installing a new Python Environment using Anaconda

To install a new env for Python, open up a command prompt and run the following:

conda create -n py3k python=3.3

You can change py3k to whatever you want to name the environment. The Python=3.3 specifies the version of python to install. Anaconda will take care of everything for you as far as downloading and installing packages.

Setting up PTVS for the new Anaconda Environment

PTVS will automatically pick up the root Anaconda environment, but any new ones created need to be specifically referenced. You can do this manually within Visual Studio:

Select:

Tools --> Options --> Python Tools --> Interpreter Options

Select:
Add Interpreter

And then give it a new name. I simply named it Python 3.3. Assuming you installed Anaconda in the default path and name the environ, use the following for the Path and Windows Path:

C:\Anaconda\envs\{env name}\python.exe
C:\Anaconda\envs\{env name}\pythonw.exe

Select the appropriate architechture and Language Version for your environment. Finally, you'll need to create a new Environment Variable for this installation. I simply used ANAPYTHONPATH. Whatever var you use, be sure to set the value of it to the following:

C:\Anaconda\envs\{env name};C:\Anaconda\envs\{env name}\Scripts

That's it! You should have full access to your new Anaconda Environment.

Comments

comments powered by Disqus