[SOLVED] Cannot load module after updating to FreeCad 0.20.1

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
karim.achaibou
Posts: 62
Joined: Tue Oct 26, 2021 5:39 pm

[SOLVED] Cannot load module after updating to FreeCad 0.20.1

Post by karim.achaibou »

hello,

I have updated from 0.19 to version 0.020.1 and now my scripts doens'nt longer find my site-packages witch are in my virtual environment.
More specific, i want to load the "icecream" module:

(works still fine in version 0.19)

Code: Select all

from icecream import ic
error:

Code: Select all

Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "C:\Program Files\FreeCAD 0.20\bin\Lib\site-packages\shiboken2\files.dir\shibokensupport\__feature__.py", line 142, in _import
    return original_import(name, *args, **kwargs)
  File "C:\Users\Achaibou Karim\AppData\Roaming\FreeCAD\Macro\fpo\tube\tube.py", line 5, in <module>
    from icecream import ic
  File "C:\Program Files\FreeCAD 0.20\bin\Lib\site-packages\shiboken2\files.dir\shibokensupport\__feature__.py", line 142, in _import
    return original_import(name, *args, **kwargs)
ModuleNotFoundError: No module named 'icecream'
I have also checked my user - and system variables and everything looks OK.

Code: Select all

OS: Windows 10 Version 2009
Word size of FreeCAD: 64-bit
Version: 0.20.1.29410 (Git)
Build type: Release
Branch: releases/FreeCAD-0-20
Hash: f5d13554ecc7a456fb6e970568ae5c74ba727563
Python 3.8.10, Qt 5.15.2, Coin 4.0.1, Vtk 8.2.0, OCC 7.6.3
Locale: Dutch/Belgium (nl_BE)
Installed mods: 
  * dodo
  * FEM_FrontISTR
  * Manipulator 1.4.9
  * ose-piping
  * sheetmetal 0.2.59
thanks in advance.
Last edited by karim.achaibou on Sat Dec 17, 2022 8:45 am, edited 1 time in total.
User avatar
onekk
Veteran
Posts: 6144
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: Cannot load module after updating to FreeCad 0.20.1

Post by onekk »

karim.achaibou wrote: Sun Dec 04, 2022 1:04 pm hello,

I have updated from 0.19 to version 0.020.1 and now my scripts doens'nt longer find my site-packages witch are in my virtual environment.
More specific, i want to load the "icecream" module:
...

thanks in advance.
Each python version has his module location.

As example if FreeCAD 0.19.x will use Python 3.6.8 and FreeCAD 0.20.1 will use Python 3.8.10 if you use FreeCAD 0.20.1 and you have not installed modules for python 3.8.10 it will not find them, and it is the "correct behaviour".

So probably you have to post even "full freecad version info" for 0.19 to sort out the problem.


Regards

Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
karim.achaibou
Posts: 62
Joined: Tue Oct 26, 2021 5:39 pm

Re: Cannot load module after updating to FreeCad 0.20.1

Post by karim.achaibou »

onekk wrote: Sun Dec 04, 2022 3:50 pm So probably you have to post even "full freecad version info" for 0.19 to sort out the problem.

Code: Select all

OS: Windows 10 Version 2009
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.24291 (Git)
Build type: Release
Branch: releases/FreeCAD-0-19
Hash: 7b5e18a0759de778b74d3a5c17eba9cb815035ac
Python version: 3.8.6+
Qt version: 5.15.2
Coin version: 4.0.1
OCC version: 7.5.0
Locale: Dutch/Belgium (nl_BE)
onekk wrote: Sun Dec 04, 2022 3:50 pm As example if FreeCAD 0.19.x will use Python 3.6.8 and FreeCAD 0.20.1 will use Python 3.8.10 if you use FreeCAD 0.20.1 and you have not installed modules for python 3.8.10 it will not find them, and it is the "correct behaviour".
my installed modules (general):

Code: Select all

C:\>pip list
Package    Version
---------- -------
colorama   0.4.6
executing  1.1.1
icecream   2.1.3
pip        22.3
Pygments   2.13.0
PySide2    5.15.2
PySide6    6.1.3
setuptools 56.0.0
shiboken2  5.15.2
shiboken6  6.1.3
six        1.16.0
my installed modules in my virtual environment:

Code: Select all

C:\Users\Achaibou Karim\AppData\Roaming\FreeCAD\Macro\fpo\venv\Scripts>activate

(venv) C:\Users\Achaibou Karim\AppData\Roaming\FreeCAD\Macro\fpo\venv\Scripts>pip list
Package         Version
--------------- -------
asttokens       2.0.8
colorama        0.4.6
et-xmlfile      1.1.0
executing       1.1.1
icecream        2.1.3
numpy           1.23.5
openpyxl        3.0.10
pandas          1.5.2
pip             21.2.4
Pygments        2.13.0
PySide2         5.15.2
python-dateutil 2.8.2
pytz            2022.6
setuptools      58.0.4
shiboken2       5.15.2
six             1.16.0
wheel           0.37.0
karim.achaibou
Posts: 62
Joined: Tue Oct 26, 2021 5:39 pm

Re: Cannot load module after updating to FreeCad 0.20.1

Post by karim.achaibou »

onekk wrote: Sun Dec 04, 2022 3:50 pm Each python version has his module location.

As example if FreeCAD 0.19.x will use Python 3.6.8 and FreeCAD 0.20.1 will use Python 3.8.10 if you use FreeCAD 0.20.1 and you have not installed modules for python 3.8.10 it will not find them, and it is the "correct behaviour".

So probably you have to post even "full freecad version info" for 0.19 to sort out the problem.
To install a package to a specific FreeCAD version, you have to install the package in de site-packages under bin\Lib\site-packages.

To install a package to a specific folder see link below:
https://stackoverflow.com/questions/291 ... -using-pip

For my "icecream" package it is done like below in the command prompt with administrator privileges:

Code: Select all

C:\>pip install --target="C:\Program Files\FreeCAD 0.20\bin\Lib\site-packages" icecream
Post Reply