hildogjr / KiCost

Build cost spreadsheet for a KiCad project.
MIT License
493 stars 97 forks source link

pip and 23.04 can't install #547

Closed mxa closed 1 year ago

mxa commented 1 year ago

ok, so 23.04 seems to have done something to pip.

pip install kicost
error: externally-managed-environment

× This environment is externally managed
╰─> To install Python packages system-wide, try apt install
    python3-xyz, where xyz is the package you are trying to
    install.

    If you wish to install a non-Debian-packaged Python package,
    create a virtual environment using python3 -m venv path/to/venv.
    Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
    sure you have python3-full installed.

    If you wish to install a non-Debian packaged Python application,
    it may be easiest to use pipx install xyz, which will manage a
    virtual environment for you. Make sure you have pipx installed.

    See /usr/share/doc/python3.11/README.venv for more information.

note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
hint: See PEP 668 for the detailed specification.

ok, so on stackexchange i find a recommendation to use pipx.

pipx install kicost
Fatal error from pip prevented installation. Full pip output in file:
    /home/mxa/.local/pipx/logs/cmd_2023-05-29_11.48.20_pip_errors.log

pip seemed to fail to build package:
    wxPython>=3.0.2

Some possibly relevant errors from pip install:
    error: subprocess-exited-with-error
    ModuleNotFoundError: No module named 'attrdict'
    error: metadata-generation-failed

Error installing kicost.

okay, in that logfile i read:

error: subprocess-exited-with-error

  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [8 lines of output]
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/tmp/pip-install-usoqlna8/wxpython_df15967db8654cdf864616f7ec488673/setup.py", line 27, in <module>
          from buildtools.config import Config, msg, opj, runcmd, canGetSOName, getSOName
        File "/tmp/pip-install-usoqlna8/wxpython_df15967db8654cdf864616f7ec488673/buildtools/config.py", line 30, in <module>
          from attrdict import AttrDict
      ModuleNotFoundError: No module named 'attrdict'
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
set-soft commented 1 year ago

ok, so 23.04 seems to have done something to pip.

This is Python policy, not Debian policy (PEP 668). You can try doing what the explanation says, this is use --break-system-packages. But I'll suggest other solution: install it from the KiBot Debian repo: https://set-soft.github.io/debian/

After adding the repo and updating the packages list you'll be able to install the kicost Debian package.

IMHO pip (and all the Python module and package system) is poorly designed and strongly biased towards inefficient Windows usage. But this seems to be the fashion of the moment. Things are even worst in the Ruby and JavaScript front.

mxa commented 1 year ago

nice, a debian package! however my config seems gone:

kicost
WARNING:(WC018) Unknown API `Octopart` (kicost - config.py:112)
WARNING:(WC017) Can't enable Digi-Key without a `client_id`, `client_secret` and `cache_path` (kicost.distributors - api_digikey.py:113)
WARNING:(WC017) Can't enable Elemen14 without a `key` (kicost.distributors - api_element14.py:253)
WARNING:(WC017) Can't enable TME without a `token` and an `app_secret` (kicost.distributors - api_tme.py:296)
WARNING:(WC017) Can't enable Nexar without a `client_id`, `client_secret` and `cache_path` (kicost.distributors - api_nexar.py:209)
Traceback (most recent call last):
  File "/home/mxa/.local/bin/kicost", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/usr/lib/python3/dist-packages/kicost/__main__.py", line 479, in main
    main_real()
  File "/usr/lib/python3/dist-packages/kicost/__main__.py", line 410, in main_real
    kicost_gui(args.force_en_us)  # Use the user gui if no input is given.
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: kicost_gui() missing 4 required positional arguments: 'files', 'configure_kicost_apis', 'command_line_api_options', and 'args'
set-soft commented 1 year ago

nice, a debian package! however my config seems gone:

Where did you save it? Is it in ~/.config/kicost/?

File "/home/mxa/.local/bin/kicost", line 8, in

Uninstall this stuff from pip, you are running an old version script that is trying to use the new kicost. The simplest thing to try is to remove /home/mxa/.local/bin/kicost, so you get the tool from /usr/bin/.

mxa commented 1 year ago

Where did you save it? Is it in ~/.config/kicost/?

Yes, there is the config.yaml

Uninstall this stuff from pip, you are running an old version script that is trying to use the new kicost. The simplest thing to try is to remove /home/mxa/.local/bin/kicost, so you get the tool from /usr/bin/.

I've removed kicost there with ~/.local/bin$ rm kicost and verified it's gone. However, still getting the similar error (this time it's /usr/local/bin/kicost)

WARNING:(WC018) Unknown API `Octopart` (kicost - config.py:112)
WARNING:(WC017) Can't enable Digi-Key without a `client_id`, `client_secret` and `cache_path` (kicost.distributors - api_digikey.py:113)
WARNING:(WC017) Can't enable Elemen14 without a `key` (kicost.distributors - api_element14.py:253)
WARNING:(WC017) Can't enable TME without a `token` and an `app_secret` (kicost.distributors - api_tme.py:296)
WARNING:(WC017) Can't enable Nexar without a `client_id`, `client_secret` and `cache_path` (kicost.distributors - api_nexar.py:209)
Traceback (most recent call last):
  File "/usr/local/bin/kicost", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/usr/lib/python3/dist-packages/kicost/__main__.py", line 479, in main
    main_real()
  File "/usr/lib/python3/dist-packages/kicost/__main__.py", line 410, in main_real
    kicost_gui(args.force_en_us)  # Use the user gui if no input is given.
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: kicost_gui() missing 4 required positional arguments: 'files', 'configure_kicost_apis', 'command_line_api_options', and 'args'

Also deleted all files in cache ~/.cache/kicost with no effect

set-soft commented 1 year ago

"/usr/local/bin/kicost"

You still have copies of KiCost at local places. You must ensure only one is installed.

mxa commented 1 year ago

after removing that one too, I get:

kicost
WARNING:(WC018) Unknown API `Octopart` (kicost - config.py:112)
WARNING:(WC017) Can't enable Digi-Key without a `client_id`, `client_secret` and `cache_path` (kicost.distributors - api_digikey.py:113)
WARNING:(WC017) Can't enable Elemen14 without a `key` (kicost.distributors - api_element14.py:253)
WARNING:(WC017) Can't enable TME without a `token` and an `app_secret` (kicost.distributors - api_tme.py:296)
WARNING:(WC017) Can't enable Nexar without a `client_id`, `client_secret` and `cache_path` (kicost.distributors - api_nexar.py:209)
Traceback (most recent call last):
  File "/usr/bin/kicost", line 33, in <module>
    sys.exit(load_entry_point('kicost==1.1.17', 'console_scripts', 'kicost')())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/kicost/__main__.py", line 479, in main
    main_real()
  File "/usr/lib/python3/dist-packages/kicost/__main__.py", line 410, in main_real
    kicost_gui(args.force_en_us)  # Use the user gui if no input is given.
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: kicost_gui() missing 4 required positional arguments: 'files', 'configure_kicost_apis', 'command_line_api_options', and 'args'
set-soft commented 1 year ago

Ok, I see. Try calling KiCost using: kicost --gui NAME_OF_THE_XML_NETLIST

set-soft commented 1 year ago

About the missing config options: run KiCost with --debug 10 option to look from where is the config loaded.

ns2gupta commented 1 year ago

About the missing config options: run KiCost with --debug 10 option to look from where is the config loaded.

Hi, i am having the same issue with the config, I recently installed the KiCost using the documentation.

after running kicost --debug i got this -

C:\Users\naman\Documents\KiCad\7.0>kicost --debug WARNING:(WC017) Can't enable Digi-Key without a client_id, client_secret and cache_path (kicost.distributors - log.py:107) WARNING:(WC017) Can't enable Mouser without a key (kicost.distributors - log.py:107) WARNING:(WC017) Can't enable Elemen14 without a key (kicost.distributors - log.py:107) WARNING:(WC017) Can't enable TME without a token and an app_secret (kicost.distributors - log.py:107) WARNING:(WC017) Can't enable Nexar without a client_id, client_secret and cache_path (kicost.distributors - log.py:107) Traceback (most recent call last): File "C:\Program Files\KiCad\7.0\bin\Lib\runpy.py", line 197, in _run_module_as_main return _run_code(code, main_globals, None, File "C:\Program Files\KiCad\7.0\bin\Lib\runpy.py", line 87, in _run_code exec(code, run_globals) File "C:\Users\naman\AppData\Local\Programs\Python\Python311\Scripts\kicost.exe__main.py", line 7, in File "C:\Program Files\KiCad\7.0\bin\Lib\site-packages\kicost__main__.py", line 479, in main main_real() File "C:\Program Files\KiCad\7.0\bin\Lib\site-packages\kicost\main__.py", line 410, in main_real kicost_gui(args.force_en_us) # Use the user gui if no input is given. TypeError: kicost_gui() missing 4 required positional arguments: 'files', 'configure_kicost_apis', 'command_line_api_options', and 'args'

set-soft commented 1 year ago

KiCost 1.1.18 should fix the no arguments issue

set-soft commented 9 months ago

I just installed 1.1.18 and still get the same warning of not finding distributors

1.1.18 fixes the missing 4 required positional arguments issue, but isn't magic.

DEBUG:Loading config from: C:\Users\Ahmed Al-Tawil.config\kicost\config.yaml (kicost - log.py:115)

Here is the file where you MUST add your tokens, KiCost can't provide tokens for you. Not at least for free.