can't install ADD-ON SDK

Talk about add-ons and extension development.
Post Reply
wuser
Posts: 17
Joined: January 2nd, 2012, 8:01 pm

can't install ADD-ON SDK

Post by wuser »

Hello, I need to make a bookmarklet that reads the content of the Search Bar ( var s = document.getElementById("searchbar"); )
And I understood that I have to install the ADD-ON SDK in order to use the window-utils module.
I have already installed Python, but when I run "activate.bat" it says:
"Failed to find Python installation directory"
I tried to add to path the installation folder (C:\Program Files\Python27) and I have also set PYTHONPATH to "C:\Program Files\Python27" but it still gives me the same error.

What am I doing wrong?
thanks
KWierso
Posts: 8829
Joined: May 7th, 2006, 10:29 pm
Location: California

Re: can't install ADD-ON SDK

Post by KWierso »

What version of the SDK are you trying to use?

I think there were problems with using Python 2.7 a while back in the SDK, but I don't remember which SDK version fixed those problems.
KWierso
Posts: 8829
Joined: May 7th, 2006, 10:29 pm
Location: California

Re: can't install ADD-ON SDK

Post by KWierso »

Oh, and activate.bat searches in the Windows registry for finding your version of python: https://github.com/mozilla/addon-sdk/bl ... tivate.bat

So it might be worth looking in the registry to make sure the entries are there.

There also might be differences between python installed "for all users" and python installed "just for me".
AlfonsoML
Posts: 387
Joined: September 6th, 2006, 1:39 pm
Contact:

Re: can't install ADD-ON SDK

Post by AlfonsoML »

And this is why most of the people won't use the Add-on SDK as long as it keeps requiring a third party framework.
wuser
Posts: 17
Joined: January 2nd, 2012, 8:01 pm

Re: can't install ADD-ON SDK

Post by wuser »

I made a mistake. I installed Python 2.7 even if it says clearly that the ADD-ON SDK needs 2.5 or 2.6.
Now I just installed Python 2.5 and the activate.bat worked and it gave me the prompt it's supposed to give.
But I don't understand how can I make use of the function I need to work: document.getElementById("searchbar");
Zoolcar9
Posts: 2225
Joined: November 9th, 2004, 6:45 pm
Location: Jakarta, Indonesia (UTC+7)
Contact:

Re: can't install ADD-ON SDK

Post by Zoolcar9 »

wuser wrote:But I don't understand how can I make use of the function I need to work: document.getElementById("searchbar");

I never used the Add-on SDK, but what if you use windows module?

Code: Select all

var window = require("windows").browserWindows.activeWindow;
var s = window.document.getElementById("searchbar");
My Firefox information | Add-ons | GitHub

"With great power, comes great desire to show it off."
wuser
Posts: 17
Joined: January 2nd, 2012, 8:01 pm

Re: can't install ADD-ON SDK

Post by wuser »

Well thanks but I see that the "windows" module is part of the same ADD-ON SDK.
And I have no idea how to make it work so I can access that function.
User avatar
LoudNoise
New Member
Posts: 39900
Joined: October 18th, 2007, 1:45 pm
Location: Next door to the west

Re: can't install ADD-ON SDK

Post by LoudNoise »

Moving to Extension Dev...
Post wrangler
"Choose between the Food Select Feature or other Functions. If no food or function is chosen, Toast is the default."
Mishkin
Posts: 2
Joined: April 23rd, 2012, 12:57 pm

Re: can't install ADD-ON SDK

Post by Mishkin »

I'm still having the Python problem of the OP, relating to installing SDK 1.6.1. I have Windows 7. Tried Python 2.5.6 and 2.6.8. I've made a new environmental variable PYTHONPATH set to the proper path like the links say. And I have administrator access. But still get "Warning: Failed to find Python installation directory" for the original version of activate.bat that comes with SDK.

Following the bug found at https://bugzilla.mozilla.org/show_bug.cgi?id=571843, an alternate version of activate.bat produces "Could not find Python. Make sure you have python installed".

The first error message has three google hits: this thread, the bug report, and an online copy of activate.bat. The second error message only has the equivalent of the latter hit.

What on earth is going on? Help appreciated.
KWierso
Posts: 8829
Joined: May 7th, 2006, 10:29 pm
Location: California

Re: can't install ADD-ON SDK

Post by KWierso »

Are you trying to do this from Windows Command Prompt or something like Cygwin?
Mishkin
Posts: 2
Joined: April 23rd, 2012, 12:57 pm

Re: can't install ADD-ON SDK

Post by Mishkin »

Command Prompt. Does it make a difference?
KWierso
Posts: 8829
Joined: May 7th, 2006, 10:29 pm
Location: California

Re: can't install ADD-ON SDK

Post by KWierso »

Someone earlier today was having the same problem when using cygwin and fixed it by installing the Windows Python installer and switching to the command prompt.

The SDK looks in a few places in the Registry for the path to Python. When I get back to my computer, I can tell you where to look.
MikaelDev
New Member
Posts: 1
Joined: July 31st, 2013, 8:36 pm

Re: can't install ADD-ON SDK

Post by MikaelDev »

Hi, I know this is a pretty old thread, but it's the first result when you search for ""Failed to find Python installation directory" using Google (for me anyway).

I had this issue when I tried to install the addon-SDK just now. I tried different versions of Python (starting with 2.7.4 - which the addon SDK readme suggests is supported: "make sure you've installed Python 2.5, 2.6, or 2.7", but then tried 2.5), but it didn't help. So I started poking around in the activate.bat file. It seems this issue occurs when (in my case at least) you install Python to a directory with a space in its name.

The Python installer (really, it would be helpful if the SDK mentioned that you should be looking for a .msi installer for Python and NOT the source files, because it's not obvious, and the former is less easy to locate on the Python home page) prompts you to install in (for example): "c:\Python27" but I changed this to "c:\program files\python27" - the batch file has a part in the ":CheckPython" subroutine which says "rem Remove spaces." - and it does... so it converts "c:\program files\python27" to "c:\programfiles\python27" which, of course, doesn't work.

So I edited activate.bat. This is going to look confusing, so I'll post the segment of the original file first, then my modification for comparison.

Original text:

rem Remove the REG_SZ
set PYTHONINSTALL=%PYTHONINSTALL:REG_SZ=%
rem Remove tabs (note the literal \t in the next line
set PYTHONINSTALL=%PYTHONINSTALL: =%
rem Remove spaces.
set PYTHONINSTALL=%PYTHONINSTALL: =%
if exist %PYTHONINSTALL%\python.exe goto :EOF


Modified text:

rem Remove the REG_SZ
set PYTHONINSTALL=%PYTHONINSTALL:REG_SZ=%
rem Remove tabs (note the literal \t in the next line
set PYTHONINSTALL=%PYTHONINSTALL: =%
REM Update 1
rem Grab first 7 characters of extracted path -> is it a path, or did the reg check fail?
SET PYTHONINSTALL_START=%PYTHONINSTALL:~0,7%
IF NOT "%PYTHONINSTALL_START%"=="REG_SZ=" (
REM Convert path to 8.3 format (because it can't have spaces in it)
for %%f in ("%PYTHONINSTALL%") do @echo %%~sf > %TEMP%\echooutput.txt
SET /p PYTHONINSTALL=<%TEMP%\echooutput.txt
DEL %TEMP%\echooutput.txt
)
rem Remove spaces.
REM We still need this to remove supirious spaces at the end of the path
set PYTHONINSTALL=%PYTHONINSTALL: =%
if exist %PYTHONINSTALL%python.exe goto :EOF

...and now it works for me.
ysap
New Member
Posts: 1
Joined: May 9th, 2015, 4:10 pm

Re: can't install ADD-ON SDK

Post by ysap »

A couple of days ago I downloaded the Add On SDK and tried installing it, following the steps in the tutorial. Before installing the SDK, I downloaded and installed Python 2.7.9, but changed its default location to "C:\Program Files (x86)\Python27". I then followed to activate the SDK and found myself struggling for a long time with the bin\activate script - because it could not find the Python installation.

It took some time and effort to analyze the script and figure out it reads the location from the registry, but then slays it due to bad parsing. Googling for the problem, I could find only a couple of mentions for that problem, and my assumption is that most users just install Python at the default location (which is not a problem for the activations script).

As mentioned in this thread, the source of the problem is the removal of spaces from the registry string. MIkaelDev's workaround will (probably) solve the problem when installing to "C:\Program Files". But there is a 2nd problem, which is looking for the ")>" as delimiters in the FOR command. Consequently, the command extracts the substring "Program Files (x86", missing the closing ")".

I then solved the problem by manually setting the variable to the correct path, bypassing the automatic search, but this is obviously a very specific solution.

This thread, and the other one dealing with the issue are very old. How come this problem was not solved by this time??
Post Reply