How can I install python packages for use with kicad scripting? Are these required to do scripting with pcbnew? I am following this pcbnew tutorial:
In particular I am trying to run recipe.py in the scripting console (like at 9:51 of this youtube video: https://www.youtube.com/watch?v=av5HwAFl2VI&feature=youtu.be). The kicad console complains that I don’t have numpy installed. So…
I’ve tried opening a cmd prompt as administrator and
cd \Program Files\KiCad\bin
pip install numpy
which fails. (see output below)
I’ve also tried the suggested work around (Kicad python pip is working?) to run pip from the BOM console, which results in the same errors. In that thread @maui suggests building with mingw might work for other packages, but not numpy (I’m unfamiliar with mingw).
There’s also this (which didn’t seem to give a clear answer): Anyone installed NumPy for use with KiCAD's python?
I find it really weird that an example pcbnew script would require a library that I can’t easily get.
after ‘pip install numpy’ the terminal replies:
> C:\Program Files\KiCad\bin>pip install numpy
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 numpy
Using cached numpy-1.16.6.zip (5.1 MB)
Using legacy 'setup.py install' for numpy, since package 'wheel' is not installed.
Installing collected packages: numpy
Running setup.py install for numpy ... error
ERROR: Command errored out with exit status 1:
command: 'c:/program files/kicad/bin/python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'c:\\users\\nevetts\\appdata\\local\\temp\\pip-install-w7ks_f\\numpy\\setup.py'"'"'; __file__='"'"'c:\\users\\nevetts\\appdata\\local\\temp\\pip-install-w7ks_f\\numpy\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'c:\users\nevetts\appdata\local\temp\pip-record-jb_kzs\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\program files\kicad\include\python2.7\numpy'
cwd: c:\users\nevetts\appdata\local\temp\pip-install-w7ks_f\numpy\
Complete output (68 lines):
Running from numpy source directory.
Note: if you need reliable uninstall behavior, then install
with pip instead of using `setup.py install`:
- `pip install .` (from a git repo or downloaded source
release)
- `pip install numpy` (last NumPy release on PyPi)
blas_opt_info:
blas_mkl_info:
Looking for python27.dll
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "c:\users\nevetts\appdata\local\temp\pip-install-w7ks_f\numpy\setup.py", line 419, in <module>
setup_package()
File "c:\users\nevetts\appdata\local\temp\pip-install-w7ks_f\numpy\setup.py", line 411, in setup_package
setup(**metadata)
File "c:\users\nevetts\appdata\local\temp\pip-install-w7ks_f\numpy/numpy/distutils/core.py", line 137, in setup
config = configuration()
File "c:\users\nevetts\appdata\local\temp\pip-install-w7ks_f\numpy\setup.py", line 164, in configuration
config.add_subpackage('numpy')
File "c:\users\nevetts\appdata\local\temp\pip-install-w7ks_f\numpy/numpy/distutils/misc_util.py", line 1036, in add_subpackage
caller_level = 2)
File "c:\users\nevetts\appdata\local\temp\pip-install-w7ks_f\numpy/numpy/distutils/misc_util.py", line 1005, in get_subpackage
caller_level = caller_level + 1)
File "c:\users\nevetts\appdata\local\temp\pip-install-w7ks_f\numpy/numpy/distutils/misc_util.py", line 942, in _get_configuration_from_setup_py
config = setup_module.configuration(*args)
File "numpy\setup.py", line 10, in configuration
config.add_subpackage('core')
File "c:\users\nevetts\appdata\local\temp\pip-install-w7ks_f\numpy/numpy/distutils/misc_util.py", line 1036, in add_subpackage
caller_level = 2)
File "c:\users\nevetts\appdata\local\temp\pip-install-w7ks_f\numpy/numpy/distutils/misc_util.py", line 1005, in get_subpackage
caller_level = caller_level + 1)
File "c:\users\nevetts\appdata\local\temp\pip-install-w7ks_f\numpy/numpy/distutils/misc_util.py", line 942, in _get_configuration_from_setup_py
config = setup_module.configuration(*args)
File "numpy\core\setup.py", line 760, in configuration
blas_info = get_info('blas_opt', 0)
File "c:\users\nevetts\appdata\local\temp\pip-install-w7ks_f\numpy/numpy/distutils/system_info.py", line 446, in get_info
return cl().get_info(notfound_action)
File "c:\users\nevetts\appdata\local\temp\pip-install-w7ks_f\numpy/numpy/distutils/system_info.py", line 639, in get_info
self.calc_info()
File "c:\users\nevetts\appdata\local\temp\pip-install-w7ks_f\numpy/numpy/distutils/system_info.py", line 1626, in calc_info
blas_mkl_info = get_info('blas_mkl')
File "c:\users\nevetts\appdata\local\temp\pip-install-w7ks_f\numpy/numpy/distutils/system_info.py", line 446, in get_info
return cl().get_info(notfound_action)
File "c:\users\nevetts\appdata\local\temp\pip-install-w7ks_f\numpy/numpy/distutils/system_info.py", line 639, in get_info
self.calc_info()
File "c:\users\nevetts\appdata\local\temp\pip-install-w7ks_f\numpy/numpy/distutils/system_info.py", line 1088, in calc_info
info = self.check_libs2(lib_dirs, mkl_libs)
File "c:\users\nevetts\appdata\local\temp\pip-install-w7ks_f\numpy/numpy/distutils/system_info.py", line 795, in check_libs2
exts = self.library_extensions()
File "c:\users\nevetts\appdata\local\temp\pip-install-w7ks_f\numpy/numpy/distutils/system_info.py", line 754, in library_extensions
c = customized_ccompiler()
File "c:\users\nevetts\appdata\local\temp\pip-install-w7ks_f\numpy/numpy/distutils/__init__.py", line 32, in customized_ccompiler
c = ccompiler.new_compiler(plat=plat, compiler=compiler)
File "c:\users\nevetts\appdata\local\temp\pip-install-w7ks_f\numpy/numpy/distutils/ccompiler.py", line 765, in new_compiler
compiler = klass(None, dry_run, force)
File "c:\users\nevetts\appdata\local\temp\pip-install-w7ks_f\numpy/numpy/distutils/mingw32ccompiler.py", line 103, in __init__
build_import_library()
File "c:\users\nevetts\appdata\local\temp\pip-install-w7ks_f\numpy/numpy/distutils/mingw32ccompiler.py", line 415, in build_import_library
return _build_import_library_amd64()
File "c:\users\nevetts\appdata\local\temp\pip-install-w7ks_f\numpy/numpy/distutils/mingw32ccompiler.py", line 464, in _build_import_library_amd64
dll_file = find_python_dll()
File "c:\users\nevetts\appdata\local\temp\pip-install-w7ks_f\numpy/numpy/distutils/mingw32ccompiler.py", line 285, in find_python_dll
raise ValueError("%s not found in %s" % (dllname, lib_dirs))
ValueError: python27.dll not found in ['c:/program files/kicad\\', 'c:/program files/kicad\\lib', 'c:/program files/kicad\\bin', 'C:\\Windows\\System32']
----------------------------------------
ERROR: Command errored out with exit status 1: 'c:/program files/kicad/bin/python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'c:\\users\\nevetts\\appdata\\local\\temp\\pip-install-w7ks_f\\numpy\\setup.py'"'"'; __file__='"'"'c:\\users\\nevetts\\appdata\\local\\temp\\pip-install-w7ks_f\\numpy\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'c:\users\nevetts\appdata\local\temp\pip-record-jb_kzs\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\program files\kicad\include\python2.7\numpy' Check the logs for full command output.
If I try another library, like scipy, I get something similar but with different error outputs:
> C:\Program Files\KiCad\bin>pip install scipy
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 scipy
Using cached scipy-1.2.3.tar.gz (23.3 MB)
ERROR: Command errored out with exit status 1:
command: 'c:/program files/kicad/bin/python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'c:\\users\\nevetts\\appdata\\local\\temp\\pip-install-dul1vn\\scipy\\setup.py'"'"'; __file__='"'"'c:\\users\\nevetts\\appdata\\local\\temp\\pip-install-dul1vn\\scipy\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'c:\users\nevetts\appdata\local\temp\pip-pip-egg-info-sctdgs'
cwd: c:\users\nevetts\appdata\local\temp\pip-install-dul1vn\scipy\
Complete output (52 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "c:\users\nevetts\appdata\local\temp\pip-install-dul1vn\scipy\setup.py", line 492, in <module>
setup_package()
File "c:\users\nevetts\appdata\local\temp\pip-install-dul1vn\scipy\setup.py", line 488, in setup_package
setup(**metadata)
File "c:\program files\kicad\lib\python2.7\site-packages/setuptools/__init__.py", line 144, in setup
_install_setup_requires(attrs)
File "c:\program files\kicad\lib\python2.7\site-packages/setuptools/__init__.py", line 139, in _install_setup_requires
dist.fetch_build_eggs(dist.setup_requires)
File "c:\program files\kicad\lib\python2.7\site-packages/setuptools/dist.py", line 719, in fetch_build_eggs
replace_conflicting=True,
File "c:\program files\kicad\lib\python2.7\site-packages/pkg_resources/__init__.py", line 782, in resolve
replace_conflicting=replace_conflicting
File "c:\program files\kicad\lib\python2.7\site-packages/pkg_resources/__init__.py", line 1065, in best_match
return self.obtain(req, installer)
File "c:\program files\kicad\lib\python2.7\site-packages/pkg_resources/__init__.py", line 1077, in obtain
return installer(requirement)
File "c:\program files\kicad\lib\python2.7\site-packages/setuptools/dist.py", line 786, in fetch_build_egg
return cmd.easy_install(req)
File "c:\program files\kicad\lib\python2.7\site-packages/setuptools/command/easy_install.py", line 679, in easy_install
return self.install_item(spec, dist.location, tmpdir, deps)
File "c:\program files\kicad\lib\python2.7\site-packages/setuptools/command/easy_install.py", line 705, in install_item
dists = self.install_eggs(spec, download, tmpdir)
File "c:\program files\kicad\lib\python2.7\site-packages/setuptools/command/easy_install.py", line 890, in install_eggs
return self.build_and_install(setup_script, setup_base)
File "c:\program files\kicad\lib\python2.7\site-packages/setuptools/command/easy_install.py", line 1158, in build_and_install
self.run_setup(setup_script, setup_base, args)
File "c:\program files\kicad\lib\python2.7\site-packages/setuptools/command/easy_install.py", line 1144, in run_setup
run_setup(setup_script, args)
File "c:\program files\kicad\lib\python2.7\site-packages/setuptools/sandbox.py", line 253, in run_setup
raise
File "c:\program files\kicad\lib\python2.7/contextlib.py", line 35, in __exit__
self.gen.throw(type, value, traceback)
File "c:\program files\kicad\lib\python2.7\site-packages/setuptools/sandbox.py", line 195, in setup_context
yield
File "c:\program files\kicad\lib\python2.7/contextlib.py", line 35, in __exit__
self.gen.throw(type, value, traceback)
File "c:\program files\kicad\lib\python2.7\site-packages/setuptools/sandbox.py", line 166, in save_modules
saved_exc.resume()
File "c:\program files\kicad\lib\python2.7\site-packages/setuptools/sandbox.py", line 141, in resume
six.reraise(type, exc, self._tb)
File "c:\program files\kicad\lib\python2.7\site-packages/setuptools/sandbox.py", line 154, in save_modules
yield saved
File "c:\program files\kicad\lib\python2.7\site-packages/setuptools/sandbox.py", line 195, in setup_context
yield
File "c:\program files\kicad\lib\python2.7\site-packages/setuptools/sandbox.py", line 250, in run_setup
_execfile(setup_script, ns)
File "c:\program files\kicad\lib\python2.7\site-packages/setuptools/sandbox.py", line 45, in _execfile
exec(code, globals, locals)
File "c:\users\nevetts\appdata\local\temp\easy_install-0yjpvv\numpy-1.20.1\setup.py", line 30, in <module>
RuntimeError: Python version >= 3.7 required.
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.