- Muchas notas - Fran Acién

20240110 - Inventree Part Import getting started

I installed inventree_part_import for importing components from mouser to my inventree. Here I am going to put my configuration.

It is not possible to install it in a external machine with ssh.

How to install it with pyenv

  1. Install Python3.10, use pyenv, it works fine
  2. Create a virtual environment, with pyenv the python version is under /home/facien/.pyenv/versions/3.10.13
  3. Install inventree-part-import

The steps with virtualenv are kinda:

pyenv install 3.10
pyenv virtualenv 3.10 inventree-venv
pyenv activate inventree-venv
pyenv deactivate # Deactivate
pyenv virtualenv-delete inventree-venv # Delete inventree-venv venv

Install packages in virtualenv, after activating the venv:

pip install inventree-part-import
pip install inventree==0.13.3
pip install digikey-api

Setup digikey-api

pip install digikey-api

mkdir -p path/to/cache/dir

export DIGIKEY_CLIENT_ID="HHH"
export DIGIKEY_CLIENT_SECRET="HHH"
export DIGIKEY_STORAGE_PATH="/home/facien/common/altium/conf/inventree-part-import/cache_digikey"

I created a file with the vars, just run:

$ source export_vars

Then run the next code:

import os
from pathlib import Path

import digikey
from digikey.v3.productinformation import KeywordSearchRequest
from digikey.v3.batchproductdetails import BatchProductDetailsRequest

# Query product number
dkpn = '296-6501-1-ND'
part = digikey.product_details(dkpn)

With the previous code a window will be opened and it will give you some cookies to work. Then everythin is readin and the part variable will have the desire information.

Setup inventree-part-import

Try to search for a component and then it will start asking for information, inventree-part-import 1043. The api keys are in the file export_vars in the folder.

When putting all the necessary information, it will open a browser to receive the token from digikey. After, the data will be updated in inventree.

For mouser it needs to be done:

The config should look something like this:

currency: 'EUR'
language: 'en'
location: 'DK'
scraping: true
datasheets: link
interactive: twice
max_results: 10
request_timeout: 15.0
retry_timeout: 3.0