'Python Tools Package' package did not load correctly. "Illegal characters in path"?

Jan 31, 2013 at 7:13 PM
Edited Jan 31, 2013 at 7:14 PM
I get the following error when I attempt to open my copy of Visual Studio Ultimate 2010 after installing PTVS:
The 'Python Tools Package' package did not load correctly.

The problem may have been caused by a configuration change or by the installation of another extension.
And then it suggested running with the /log command and examining the ActivityLog.xml file in AppData\Roaming\Microsoft\VisualStudio\10.0\

I did that and this is the error entry I found:

<entry>
<record>444</record>
<time>2013/01/31 18:38:16.536</time>
<type>Error</type>
<source>VisualStudio</source>
<description>End package load [Python Tools Package]</description>
<guid>{6DBD7C1E-1F1B-496D-AC7C-C55DAE66C783}</guid>
<hr>80131500</hr>
<errorinfo>The composition produced a single composition error. The root cause is provided below. Review the CompositionException.Errors property for more detailed information.
1) Illegal characters in path.

Resulting in: An exception occurred while trying to create an instance of type 'Microsoft.PythonTools.Interpreter.Default.CPythonInterpreterFactoryProvider'.

Resulting in: Cannot activate part 'Microsoft.PythonTools.Interpreter.Default.CPythonInterpreterFactoryProvider'.
Element: Microsoft.PythonTools.Interpreter.Default.CPythonInterpreterFactoryProvider --> Microsoft.PythonTools.Interpreter.Default.CPythonInterpreterFactoryProvider --> AssemblyCatalog (Assembly="Microsoft.PythonTools.Analysis, Version=1.8.40818.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")

Resulting in: Cannot get export 'Microsoft.PythonTools.Interpreter.Default.CPythonInterpreterFactoryProvider (ContractName="Microsoft.PythonTools.Interpreter.Default.IDefaultInterpreterFactoryCreator")' from part 'Microsoft.PythonTools.Interpreter.Default.CPythonInterpreterFactoryProvider'.
Element: Microsoft.PythonTools.Interpreter.Default.CPythonInterpreterFactoryProvider (ContractName="Microsoft.PythonTools.Interpreter.Default.IDefaultInterpreterFactoryCreator") --> Microsoft.PythonTools.Interpreter.Default.CPythonInterpreterFactoryProvider --> AssemblyCatalog (Assembly="Microsoft.PythonTools.Analysis, Version=1.8.40818.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")

Resulting in: Cannot set import 'Microsoft.PythonTools.ConfigurablePythonInterpreterFactoryProvider..ctor (Parameter="defaultCreator", ContractName="Microsoft.PythonTools.Interpreter.Default.IDefaultInterpreterFactoryCreator")' on part 'Microsoft.PythonTools.ConfigurablePythonInterpreterFactoryProvider'.
Element: Microsoft.PythonTools.ConfigurablePythonInterpreterFactoryProvider..ctor (Parameter="defaultCreator", ContractName="Microsoft.PythonTools.Interpreter.Default.IDefaultInterpreterFactoryCreator") --> Microsoft.PythonTools.ConfigurablePythonInterpreterFactoryProvider --> AssemblyCatalog (Assembly="Microsoft.PythonTools, Version=1.8.40818.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")

Resulting in: Cannot get export 'Microsoft.PythonTools.ConfigurablePythonInterpreterFactoryProvider (ContractName="Microsoft.PythonTools.Interpreter.IPythonInterpreterFactoryProvider")' from part 'Microsoft.PythonTools.ConfigurablePythonInterpreterFactoryProvider'.
Element: Microsoft.PythonTools.ConfigurablePythonInterpreterFactoryProvider (ContractName="Microsoft.PythonTools.Interpreter.IPythonInterpreterFactoryProvider") --> Microsoft.PythonTools.ConfigurablePythonInterpreterFactoryProvider --> AssemblyCatalog (Assembly="Microsoft.PythonTools, Version=1.8.40818.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
</errorinfo>
</entry>

Could someone give me some insight on what the issue might be?

Thanks,
Alex
Coordinator
Jan 31, 2013 at 8:31 PM
I suspect you have a Python interpreter listed in your registry which has an invalid path. We should probably handle the bad path and ignore the interpreter in that case, so I'll open a bug.

If you start regedit and go to HLKM\Software\Python\PythonCore\<version>\InstallPath (and/or HLKM\Software\Wow6432Node\Python\PythonCore\<version>\InstallPath if you're on a 64-bit machine) and look at the values there's probably one weird one with invalid filename characters.

I'm also a little curious how it would have gotten there so if this is the problem if you can report back what's there that could be helpful.
Coordinator
Jan 31, 2013 at 8:34 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Coordinator
Jan 31, 2013 at 8:42 PM
Firstly, you should upgrade from PTVS 1.0 to PTVS 1.5. There have been a lot of fixes in the last 18 months. (The VS 2010 version is on the downloads page, about halfway down the list of files.)

If you've already installed PTVS 1.5, uninstall it, look for the install path and delete it, then reinstall.

If that doesn't help, which versions of CPython do you have installed and what are their full paths? The function throwing the exception is part of where we detect installed CPython interpreters using the registry. Under (HKLM|HKCU)\SOFTWARE\Python\PythonCore there is a list of interpreter keys and we look in their InstallPath keys. It is possible that one of these has become corrupted, or that you've installed CPython into a configuration that we haven't tested.
Jan 31, 2013 at 10:52 PM
Edited Jan 31, 2013 at 10:54 PM
In the work item you created I checked the link you cited as similar to my issue and came to a solution from the information there, along with your replies to this discussion.

My current version of CPython is 2.7.3, I've had other versions previously but I uninstalled them all prior to now; there were some left over registry keys for them that I noticed while checking the registry and which I deleted. They may have been the ones which contained invalid characters which threw the initial error, as they were part of a strange installation configuration I was required to use for a previous project. Those installations of Python used a custom installer built for the project and were heavily reliant on a specific system configuration because they were part of a build system; so I think whatever invalid characters got in there are unique to my situation.

My current python path is the very basic default: C:\Python27\

My registry paths for my current CPython were:
HKLM\SOFTWARE\Python\PythonCore\2.7\InstallPath
HKLM\Wow6432Node\Python\PythonCore\2.7 
The one under WoW6432Node had no InstallPath listed under it, so I added one that was the same as the one under SOFTWARE. After doing this I installed PTVS 1.5 once again and no errors occurred on launch of VS 2010 this time.

This may not have been required since PTVS might have just found the one under SOFTWARE once I cleared out the old registry keys from the old Python installations I had, but I added it just to be sure.

Thanks very much for your help. Glad my troubles should at least help your software be more robust.
Coordinator
Jan 31, 2013 at 10:59 PM
Great, glad that fixed it, and thanks for the additional info!