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
- Install Python3.10, use pyenv, it works fine
- Create a virtual environment, with pyenv the python version is under
/home/facien/.pyenv/versions/3.10.13
- 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
- Is necessary to setup the digikey configuration with -> https://github.com/30350n/inventree_part_import?tab=readme-ov-file#digikey
- Basically is using this guide and the outh would be localhost something
- I was not able to configure it, on mouser it was not able to find the component and in digikey I was not able to sign in.
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:
- Get search api from here
- The host will be:
mouser.dk
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