2

Resolved

Right-click Pylint command not present

description

Hi,
I've installed the Alpha 2.1 PTVS on VS2013 (premium edition with update 1). I also have python 3.3.2 x86 (but not in my OS path) and have added pip and pylint to the python folders.

If I create a new python project from existing code. Once created I right click the project (or other files), I do not see the "Python" menu option above the "Publish". So I'm unable to access the Pylint command.

BTW: PTVS is excellent and productive tool within VS. I was very excited to see the addition of pylint to VS output, as a relative new comer to python it would be a big help.

Are there any workaround to access pylint within VS?

Cheers,
Chris Davies

file attachments

comments

Zooba wrote Mar 26 at 3:21 PM

Can you look in your .pyproj file to see whether we have this code near the end:
  <PropertyGroup>
    <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
    <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
    <PtvsTargetsFile>$(VSToolsPath)\Python Tools\Microsoft.PythonTools.targets</PtvsTargetsFile>
  </PropertyGroup>
  <Import Condition="Exists($(PtvsTargetsFile))" Project="$(PtvsTargetsFile)" />
  <Import Condition="!Exists($(PtvsTargetsFile))" Project="$(MSBuildToolsPath)\Microsoft.Common.targets" />
If not, you probably have a single Import element, which should be replaced with the code above.

This looks like it was a bug in 2.1 Alpha that has been fixed for Beta (or the latest dev build). However, even in the latest versions we still won't automatically convert old projects to include this code - it's on our list of things to do.

j_chris_davies wrote Mar 27 at 7:21 PM

Great - that solved it, I just had the single Import element:
  <Import Project="$(MSBuildToolsPath)\Microsoft.Common.targets" />
Replacing with the section above enabled the command and PyLint ran successfully.

Many thanks,
Chris.

jmwachtel wrote Mar 31 at 1:29 PM

I have attempted to use PTVS 2.1 alpha and the latest development branch both by creating a new project, and using the code posted by Zooba, and I have been unable to ever see the python menu. What am I doing wrong?

Zooba wrote Mar 31 at 3:33 PM

You may not be doing anything wrong. This is only an Alpha, so it's entirely possible that something just does not work in every scenario. Hence why we release early versions - to find out what those are :)

Are you able to post or share a screenshot of the menu you see when you right click on your Python project? You can email it to ptvshelp@microsoft.com or attach it here (I'd prefer it attached, to help out anyone else who comes along with a similar problem).

jmwachtel wrote Mar 31 at 4:32 PM

I click on the project and get the menu as attached.

Zooba wrote Mar 31 at 4:54 PM

Can you check whether the following file exists?

C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\Python Tools\Microsoft.PythonTools.targets

(Adjusting the (x86) if necessary and use v11.0 if you're on VS 2012 and not VS 2013.)

jmwachtel wrote Mar 31 at 5:25 PM

Yes, the file is there. Here is a test project file:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <SchemaVersion>2.0</SchemaVersion>
    <ProjectGuid>{dfb56668-aa68-4398-9730-ca63a6e9c40b}</ProjectGuid>
    <ProjectHome />
    <StartupFile>test.py</StartupFile>
    <SearchPath />
    <WorkingDirectory>.</WorkingDirectory>
    <OutputPath>.</OutputPath>
    <ProjectTypeGuids>{888888a0-9f3d-457c-b088-3a5042f75d52}</ProjectTypeGuids>
    <LaunchProvider>Standard Python launcher</LaunchProvider>
    <InterpreterId />
    <InterpreterVersion />
    <PtvsTargetsFile>$(VSToolsPath)\Python Tools\Microsoft.PythonTools.targets</PtvsTargetsFile>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)' == 'Debug'" />
  <PropertyGroup Condition="'$(Configuration)' == 'Release'" />
  <PropertyGroup>
    <VisualStudioVersion Condition=" '$(VisualStudioVersion)' == '' ">10.0</VisualStudioVersion>
    <VSToolsPath Condition=" '$(VSToolsPath)' == '' ">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
  </PropertyGroup>
  <ItemGroup>
    <Compile Include="test.py" />
  </ItemGroup>
  <Import Project="$(PtvsTargetsFile)" Condition="Exists($(PtvsTargetsFile))" />
  <Import Project="$(MSBuildToolsPath)\Microsoft.Common.targets" Condition="!Exists($(PtvsTargetsFile))" />
</Project>

Zooba wrote Mar 31 at 5:50 PM

If you create a new Flask, Bottle or Django project, do you see a "Web" menu? (It may say "Python", depending on the version of PTVS you are using.)

jmwachtel wrote Mar 31 at 6:02 PM

Ok, it seemed to work if I created a python application project, but not if I select the "Create from existing code" option. Here is the test project using the python application option:
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <SchemaVersion>2.0</SchemaVersion>
    <ProjectGuid>3940e9d1-bb48-4003-9a36-ac75bd60ec3e</ProjectGuid>
    <ProjectHome>.</ProjectHome>
    <StartupFile>test.py</StartupFile>
    <SearchPath>
    </SearchPath>
    <WorkingDirectory>.</WorkingDirectory>
    <OutputPath>.</OutputPath>
    <Name>test</Name>
    <RootNamespace>test</RootNamespace>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
    <DebugSymbols>true</DebugSymbols>
    <EnableUnmanagedDebugging>false</EnableUnmanagedDebugging>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
    <DebugSymbols>true</DebugSymbols>
    <EnableUnmanagedDebugging>false</EnableUnmanagedDebugging>
  </PropertyGroup>
  <ItemGroup>
    <Compile Include="test.py" />
  </ItemGroup>
  <PropertyGroup>
    <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
    <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
    <PtvsTargetsFile>$(VSToolsPath)\Python Tools\Microsoft.PythonTools.targets</PtvsTargetsFile>
  </PropertyGroup>
  <Import Condition="Exists($(PtvsTargetsFile))" Project="$(PtvsTargetsFile)" />
  <Import Condition="!Exists($(PtvsTargetsFile))" Project="$(MSBuildToolsPath)\Microsoft.Common.targets" />
</Project>

Zooba wrote Mar 31 at 6:29 PM

Ah I see what's happened. Obviously when we create the project from existing code, we get some properties in the wrong order.

In your first project, the PtvsTargetsFile property is set before VSToolsPath, which means the path will be incorrect. If you move it to near the end of the file, it should work properly.

I'll fix it up, though it won't make it into our Beta release.