David James
David James

Reputation: 11

Receiving error "Not a valid Python module" in Visual Studio Community 2015

I am struggling to get Python Tools working with Visual Studio. If I create a "Hello World" new application then it seems fine but if I try to import a script from github then I receive the error quoted below.

If I create a new project and then cut and paste the same script from github then there is no error.

If I then graft in the .git folder then it is still fine and git works. But after I close visual studio and open it again the next day the same error appears.

The error visual studio shows is:

Not a valid Python module: C:\Users\David\Documents\Visual Studio 2015\Projects\example-project\example-project\example-project.py

File: Microsoft.Python.Tools.Targets Line: 131

If I double click the error then it shows 15 warnings like these:

Warning The element 'PropertyGroup' in namespace 'http://schemas.microsoft.com/developer/msbuild/2003' has invalid child element '_PythonToolsPath' in namespace 'http://schemas.microsoft.com/developer/msbuild/2003'. List of possible elements expected: 'Property, VisualStudioVersion, MinimumVisualStudioVersion, AdditionalFileItemNames, AllowUnsafeBlocks, AppConfigForCompiler, ApplicationIcon, ApplicationRevision, ApplicationVersion, AppDesignerFolder, AspNetConfiguration, AssemblyKeyContainerName, AssemblyKeyProviderName, AssemblyName, AssemblyOriginatorKeyFile, AssemblyOriginatorKeyFileType, AssemblyOriginatorKeyMode, AssemblyType, AutoGenerateBindingRedirects, AutorunEnabled, BaseAddress, BootstrapperComponentsLocation, BootstrapperComponentsUrl, BootstrapperEnabled, CharacterSet, CheckForOverflowUnderflow, CLRSupport, UseDebugLibraries, CodePage, Configuration, ConfigurationName, ConfigurationOverrideFile, CreateDesktopShortcut, CreateWebPageOnPublish, CurrentSolutionConfigurationContents, DebugSecurityZoneURL, DebugSymbols, DebugType, DefaultClientScript, DefaultHTMLPageLayout, DefaultTargetSchema, DefineConstants, DefineDebug, DefineTrace, DelaySign, DisableLangXtns, DisallowUrlActivation, CodeAnalysisAdditionalOptions, CodeAnalysisApplyLogFileXsl, ....

Project: Miscellaneous Files

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

Line: 15

All the other warnings look very similar with missing child elements.

I googled for this and found nothing. The only other clue is that on projects which work, next to the pythonscript.py file in the Solution Explorer it shows green PY but on the ones which produce the error I see a red tick and then the green PY letter/icon.

I failed to install Visual Studio the first 3 times due to low disk space. Could I have a broken installation or am I doing something wrong here?

Upvotes: 1

Views: 1074

Answers (1)

Zooba
Zooba

Reputation: 11438

This is a bug when the filename is converted into a importable module name, which is impossible when there is a hyphen in the name.

I just filed it on the project's GitHub page.

Upvotes: 1

Related Questions