The default path to install KiCad 5.1.10 is C:\Program files\KiCad but this is a very bad idea for the Python 2.7 included with KiCad.
I just tried to install KiCost using the included Python. I tried pip install -U git+https://github.com/hildogjr/KiCost.git. Of course I had: git installed and C:\Program files\KiCad\bin in my path.
It worked, and created: C:\Program files\KiCad\bin\kicost.exe
But the .exe is useless. When you run it you get:
failed to create process (C:\Program "files\KiCad\bin\python.exe" "C:\Program files\KiCad\bin\kicost.exe").
I tried upgrading pip and also upgrading distlib. No luck.
IMHO KiCad should avoid suggesting C:\Program files\KiCad and even warn the user if installing to a path with spaces.
Can somebody confirm this problem? Comments?
I used a Windows 7 system. I’m not filling a bug report because I don’t use Windows and need confirmation from other users.
BTW: if you wonder why this isn’t a common issue: KiCost suggests to install a separated Python, which in turn implies a separated wxPython, etc. A real waste of time and disk space. I want to suggest people to just use the Python shipped with KiCad.
KiCad follows operating system conventions. In this case, Windows suggests installed programs in “Program Files”. It is unfortunate that distlib has an issue with this but to suggest that KiCad break user expectations to fix an issue in a separate package is, IMO, backwards.
microsoft ever decided to start with path names with spaces for important directories. They started with that, probably in windows 95, and has caused problems with programs for many years after that. Even now, when programs fully support it, it’s still an annoyance to work with such paths on the commandline.
I could argue that Microsoft doing that forced devs to remember that paths actually CAN have spaces in them and without MS stepping on that landmine we would have a lot more buggy software that can’t handle spaces to this day.
Maybe one days MS will take one for the team and have a non-ascii utf-8 char in some system path…
In KiCad quite many utf8 bugs have been fixed and I would bet many are still left to be found. That’s of course not a fault of Windows. Well, maybe a little… But non-ascii is problematic for any application, not just KiCad.
It’s enough for a non-English user to have a non-ascii char in their user name. See https://gitlab.com/kicad/code/kicad/-/issues/4993 for an example. Interestingly it wasn’t strictly non-ascii but characters above 00FF.
BTW, for the original problem: is it problem also in 5.99?
Do you really think that installing programs under “Program files” is a “user expectation”?
Most people doesn’t even know much about it, and even less about “Program files (x86)”, not to mention that any internationalized Windows will pretend the name is another one. My Windows pretends this is “Archivos de programa” … a fake idea most users get when using the GUI.
Currently KiCad 5.1 has Python and has pip, but pip can be used to install plain modules, no scripts for entry points if people installs to the most common path.
Does anybody know which component of Python is generating this binary stub? My guess is this stub is really generic. I have to experiment a little bit, but the solution could be as simple as replacing the stub.
python -m pip install --upgrade --force-reinstall pip should do the trick
Currently KiCad 5.1 has Python and has pip, but pip can be used to install plain modules, no scripts for entry points if people installs to the most common path.
There are other problems, any python modules that use native compiled DLLs/PYDs are incompatible with kicad 5.1 because its compiled using msys2 instead of msvc which is the main expectation in pypi.
Changing the install location will not resolve numerous issues the python distributed with kicad 5.1 that exist.
I also tried in a administrator prompt and got the following output:
C:\windows\system32>"c:\Program Files\KiCad_v5_1_10\bin\pip.exe" install -U git+https://github.com/hildogjr/KiCost.git
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.
Collecting git+https://github.com/hildogjr/KiCost.git
Cloning https://github.com/hildogjr/KiCost.git to c:\users\uestrada\appdata\local\temp\pip-req-build-i9t_qs
Running command git clone -q https://github.com/hildogjr/KiCost.git 'c:\users\uestrada\appdata\local\temp\pip-req-build-i9t_qs'
Collecting beautifulsoup4>=4.3.2
Downloading beautifulsoup4-4.9.3-py2-none-any.whl (115 kB)
|################################| 115 kB 4.1 MB/s
Requirement already satisfied, skipping upgrade: lxml>=3.7.2 in c:\program files\kicad_v5_1_10\lib\python2.7\site-packages (from kicost==1.1.5) (4.4.1)
Collecting XlsxWriter>=0.7.3
Downloading XlsxWriter-1.4.3-py2.py3-none-any.whl (149 kB)
|################################| 149 kB 6.0 MB/s
Collecting tqdm>=4.30.0
Downloading tqdm-4.61.1-py2.py3-none-any.whl (75 kB)
|################################| 75 kB 1.2 MB/s
Requirement already satisfied, skipping upgrade: requests>=2.18.4 in c:\program files\kicad_v5_1_10\lib\python2.7\site-packages (from kicost==1.1.5) (2.22.0)
Collecting validators>=0.14.2
Downloading validators-0.14.2.tar.gz (25 kB)
Requirement already satisfied, skipping upgrade: wxPython>=3.0.2 in c:\program files\kicad_v5_1_10\lib\python2.7\site-packages\wx-3.0-msw (from kicost==1.1.5) (3.0.2.0)
Requirement already satisfied, skipping upgrade: colorama in c:\program files\kicad_v5_1_10\lib\python2.7\site-packages (from kicost==1.1.5) (0.4.1)
Collecting soupsieve<2.0,>1.2; python_version < "3.0"
Using cached soupsieve-1.9.6-py2.py3-none-any.whl (33 kB)
Requirement already satisfied, skipping upgrade: chardet<3.1.0,>=3.0.2 in c:\program files\kicad_v5_1_10\lib\python2.7\site-packages (from requests>=2.18.4->kicost==1.1.5) (3.0.4)
Requirement already satisfied, skipping upgrade: idna<2.9,>=2.5 in c:\program files\kicad_v5_1_10\lib\python2.7\site-packages (from requests>=2.18.4->kicost==1.1.5) (2.8)
Requirement already satisfied, skipping upgrade: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in c:\program files\kicad_v5_1_10\lib\python2.7\site-packages (from requests>=2.18.4->kicost==1.1.5) (1.25.5)
Requirement already satisfied, skipping upgrade: certifi>=2017.4.17 in c:\program files\kicad_v5_1_10\lib\python2.7\site-packages (from requests>=2.18.4->kicost==1.1.5) (2019.6.16)
Requirement already satisfied, skipping upgrade: six>=1.4.0 in c:\program files\kicad_v5_1_10\lib\python2.7\site-packages (from validators>=0.14.2->kicost==1.1.5) (1.12.0)
Collecting decorator>=3.4.0
Downloading decorator-4.4.2-py2.py3-none-any.whl (9.2 kB)
Collecting backports.functools-lru-cache; python_version < "3"
Downloading backports.functools_lru_cache-1.6.4-py2.py3-none-any.whl (5.9 kB)
Using legacy 'setup.py install' for kicost, since package 'wheel' is not installed.
Using legacy 'setup.py install' for validators, since package 'wheel' is not installed.
Installing collected packages: backports.functools-lru-cache, soupsieve, beautifulsoup4, XlsxWriter, tqdm, decorator, validators, kicost
Running setup.py install for validators ... done
Running setup.py install for kicost ... done
Successfully installed XlsxWriter-1.4.3 backports.functools-lru-cache-1.6.4 beautifulsoup4-4.9.3 decorator-4.4.2 kicost-1.1.5 soupsieve-1.9.6 tqdm-4.61.1 validators-0.14.2
Checking PIP version:
c:\Program Files\KiCad_v5_1_10\bin>pip -V
pip 20.3.4 from c:\program files\kicad_v5_1_10\lib\python2.7\site-packages\pip (python 2.7)
Trying to run the resulting program:
c:\Program Files\KiCad_v5_1_10\bin>kicost.exe
failed to create process (c:\program "files\kicad_v5_1_10\bin\python.exe" "c:\Program Files\KiCad_v5_1_10\bin\kicost-script.py").
Ok, I narrowed the problem. Is in the following file: C:\Program files\KiCad\lib\python2.7\site-packages\setuptools\cli-64.exe
This is the generic stub, it tries to find where Python is installed and then runs Python passing as script name the name of the .exe replacing .exe by -script.py.
The last setuptools available for Python 2.7 is 44.1.1 and the last available for Python 3 is 57.0.0.
Now I found the stub isn’t wrong, I compiled it from sources.
The wrong thing is the generated script NAME-script.py the shebang line is wrong. It says #!C:\Program files\KiCad\python.exe but the stub expects #!"C:\Program files\KiCad\python.exe".