Reputation: 347
Hello im trying to figure out how to properly install Firefox Addon SDK, I've followed all the installation details such as: Installing Python 2.7, setting my PATH Variables correctly, and running the addon from my cmd.exe .. Everytime I run the command line to start developing an addon I get this error:
C:\mozilla-build\addon-sdk\bin>activate.bat
Warning: Failed to find Python installation directory
IFrom my understanding I have everything properly configured, Can anyone help with this error. And also my PATH variables are as below
User Variables...;C:\mozilla-build\addon-sdk\bin;C:\mozilla-build\python;C:\Python27
SYSTEM Variables ...;C:\mozilla-build\addon-sdk\bin;C:\mozilla-build\python;C:\Python27
Upvotes: 4
Views: 2000
Reputation: 2596
It's 2015 and I doubt most users can get the Firefox Addon SDK working on the first try without touching some code for Windows- even with Python being installed in the default location...
Here's how I got it installed using v2.7 of Python
In around line 111 of activate.bat you have:
set PYTHONINSTALL=%PYTHONINSTALL:REG_SZ=%
change to
set PYTHONINSTALL=%PYTHONINSTALL:REG_SZ="C://Python27"
Or set it to whatever location Python is installed on. That's it!
Upvotes: 2
Reputation: 12695
Here's an alternative way to isolate the path (possibly) returned by reg query, independently from Windows version:
REG_SZ
, with a unique single character, e.g. ?
. (See note later)Note:
A question mark could actually be part of a path, although that seems to be uncommon. Ideally it should be a character unallowed in paths: |
, <
, >
, and so on. But some of those gave us troubles escaping them.
There's also another issue with original code, when checking:
if exist %PYTHONINSTALL%\whatever goto :EOF
the path being checked should be enclosed in double quotes, to take into account for paths containing spaces.
So all in all, here's the alternative implementation, e.g. just for the HKML part:
rem Try HKLM
SET QueryResult=
FOR /F "usebackq delims=" %%r IN (`%reg% QUERY HKLM\%key% /ve 2^>NUL`) DO @SET QueryResult=%%r
SET ReplacedResult=%QueryResult:REG_SZ=?%
FOR /F "tokens=2 delims=?" %%t IN ("%ReplacedResult%") DO SET "%~1=%%t"
rem trim tabs and spaces from the left (note: there's a literal tab in next line)
FOR /F "tokens=* delims= " %%v IN ("%PYTHONINSTALL%") DO SET PYTHONINSTALL=%%v
if exist "%PYTHONINSTALL%\python.exe" goto :EOF
rem It may be a 32bit Python directory built from source, in which case the
rem executable is in the PCBuild directory.
if exist "%PYTHONINSTALL%\PCBuild\python.exe" (set "PYTHONINSTALL=%PYTHONINSTALL%\PCBuild" & goto :EOF)
rem Or maybe a 64bit build directory.
if exist "%PYTHONINSTALL%\PCBuild\amd64\python.exe" (set "PYTHONINSTALL=%PYTHONINSTALL%\PCBuild\amd64" & goto :EOF)
Please have a look at this Github commit to see the actual diff.
Upvotes: 0
Reputation: 10110
I had the same problem too, it seemed that changing the default installation directory for python can cause this problem.
python version 2.5, 2.6 or 2.7
.
Versions 3.x of Python will not work.C:/Python32/
.Upvotes: 4
Reputation: 96
The problem seems to be that the activate batch file having issues to set the write value of the variable PYTHONINSTALL. I solved this by setting it manually and deleting all the bloated function Mozilla used to detect the path.
open the bin\activate.bat file with an editor (np++ makes it clear to work with) under the :CheckPython label delete the function and the comments and use this to set your python installation path:
:CheckPython
::CheckPython(retVal, key)
::Reads the registry at %2% and checks if a Python exists there.
::Checks both HKLM and HKCU, then checks the executable actually exists.
SET key=%2%
SET "%~1="
SET reg=reg
if defined ProgramFiles(x86) (
if exist %WINDIR%\sysnative\reg.exe SET reg=%WINDIR%\sysnative\reg.exe
)
rem here you should make sure to set the correct path
set PYTHONINSTALL=C:\Program Files\Python27
if exist %PYTHONINSTALL%\python.exe goto :EOF
if exist %PYTHONINSTALL%\PCBuild\python.exe (set "PYTHONINSTALL=%PYTHONINSTALL%\PCBuild" & goto :EOF)
if exist %PYTHONINSTALL%\PCBuild\amd64\python.exe (set "PYTHONINSTALL=%PYTHONINSTALL%\PCBuild\amd64" & goto :EOF)
GOTO :EOF
Upvotes: 8
Reputation: 11
I had this same problem using Windows 7 and this is what I did to make it work
I don't know any more than this yet, so hopefully this fixes it!
Upvotes: 1