Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No module named openpyxl #16

Closed
Zolko-123 opened this issue Feb 6, 2024 · 14 comments
Closed

No module named openpyxl #16

Zolko-123 opened this issue Feb 6, 2024 · 14 comments

Comments

@Zolko-123
Copy link

I can now launch the BoM WB, but not use it :

cannot import name 'CheckAssemblyType' from 'General_BOM_Functions' 
Traceback (most recent call last):
...
ModuleNotFoundError: No module named 'openpyxl'
@APEbbers
Copy link
Owner

APEbbers commented Feb 6, 2024

Hi,

I think that is because I use openpyxl to convert letters to numbers and visa verca. Since yesterday, the Bill of Materials is available through the add-on manager. in the package.xml I've put openpyxl as a depency.

Does this error still happen when you install the wb via the add-on manager?

@furgo16
Copy link

furgo16 commented Feb 19, 2024

In my case, the Add-on Manager warns me of the missing dependency (but does not offer to install it). If I install the dependency manually, then I can resume the installation and it works. Running FreeCAD dev on Linux via snap.

@GRiba97
Copy link

GRiba97 commented Feb 20, 2024

Unfortunely it's still happening, I tried to install the WB via add-on manager and repeated the same mesage that @furgo16 received. For me that I'm a newbie to python, I don't even know how to install openpyxl manually. If you can help, please explain how to install manually or put openpyxl package together with the BoMWB files.

@APEbbers
Copy link
Owner

Hi,

I've updated the package.xml to the latest standard, however I don't suspect that it makes any difference.
I've followed the documentation from FreeCAD. However I know that there are some issues with snap. These are not specific for this WB as far as I can see.
I've tested the WB on Linux (Debian) with AppImage. That seems to work ok.

I did find some info regarding snap images. with information on how to install/update python packages:

I've also a link about the use of AppImages:

A alternative option to "Install" dependencies can be to do the following: ('ve done this in the past in Windows)

  • Install the python package in you local python: -> pip install openpyxl.
  • Then copy the folders: "..\Python3.11\Lib\site-packages\openpyxl" and ..\Python3.11\Lib\site-packages\openpyxl-3.1.2.dist-info"
  • Paste them in "\FreeCAD\bin\Lib\site-packages".
    I've got this approeach from: https://forum.freecad.org/viewtopic.php?p=189864#p189864

I hope this helps. In the meantime, I'll look into this further, because I plan to use openpyxl for other functions as well.

kind regards,

Paul

@M-Welsch
Copy link

M-Welsch commented Feb 25, 2024

Had the same problem. I use FreeCAD-Realthunder and I installed it using snap.

I solved it by opening the python console in FreeCAD and entering

import subprocess
subprocess.run('python -m pip install openpyxl'.split())

I guess the same works for the "vanilla" FreeCAD and without snap. Hope it helps someone :)

best
Maxi

@furgo16
Copy link

furgo16 commented Feb 29, 2024

The way I manually install Python dependencies for FreeCAD is the one documented on the snap package. E.g.:

  1. Open a system terminal, outside of FreeCAD (Ctrl+Alt+t)
  2. Type the following command
freecad.pip install openpyxl

@mwlandolsi
Copy link

None of the above solutions worked for me!
[code]
OS: KDE Flatpak runtime (X-Cinnamon/cinnamon)
Word size of FreeCAD: 64-bit
Version: 0.21.2.33771 (Git)
Build type: Release
Branch: (HEAD detached at b9bfa5c)
Hash: b9bfa5c5507506e4515816414cd27f4851d00489
Python 3.11.7, Qt 5.15.10, Coin 4.0.0, Vtk 8.2.0, OCC 7.6.3
Locale: English/United States (en_US)
Installed mods:

  • sheetmetal 0.4.2
  • frame 0.1.1
  • Movie 2023.6.10
  • Assembly3 0.12.0
  • Curves 0.6.13
  • 3DfindIT 1.2.0
  • lattice2 1.0.0
  • BillOfMaterials 0.0.5.7
  • Silk 0.1.5
  • freecad.gears 1.0.0
  • Render 2023.8.18
  • fasteners 0.4.67
    [/code]

@APEbbers
Copy link
Owner

APEbbers commented Mar 7, 2024

I've maybe another option. Can you try to run the following from a terminal:

"C:\Program Files\FreeCAD 0.21\bin\python.exe" -m pip install openpyxl.

Change the path of course to where your FreeCAD is located
I just tried it on my laptop. In windows, but I think it should work in Linux as well.

@Zolko-123
Copy link
Author

Zolko-123 commented Mar 7, 2024

I use openpyxl to convert letters to numbers and visa versa

do you absolutely need openpyxl for that ?

openpyxl - A Python library to read/write Excel 2010 xlsx/xlsm files ????

@mwlandolsi
Copy link

I use openpyxl to convert letters to numbers and visa versa

do you absolutely need openpyxl for that ?

openpyxl - A Python library to read/write Excel 2010 xlsx/xlsm files ????

But it shows an error when selecting the WB! I wonder if it is necessary to run the WB?

@APEbbers
Copy link
Owner

APEbbers commented Mar 7, 2024

I'm planning to use it for future functions. I've also another workbench that depends heavily on it.
I find it strange that it causes these issues since this library is officially allowed by FreeCAD and is used with other WB like OSAFE for example.

Since I want to use it more, I'd like to understand why this occurs. I'll going to look into it futher this weekend.

@furgo16
Copy link

furgo16 commented Mar 8, 2024

@mwlandolsi: at this point, you might want to seek forum help to resolve your installation issue: https://forum.freecad.org/viewtopic.php?t=84982

[APEbbers]: However I know that there are some issues with snap. These are not specific for this WB as far as I can see.

I had no issues with snap, other than having to install the dependency manually.

[APEbbers]: I use openpyxl to convert letters to numbers and visa versa

[Zolko-123]: do you absolutely need openpyxl for that ?

If it's only used for letter to digit conversion, would it not be simpler from a maintenance and installation point of view to use plain Python now and adopt the library if and when the future functions are added? Just a thought, thanks a lot for releasing the workbench!

@furgo16
Copy link

furgo16 commented Mar 9, 2024

@APEbbers could it be because the package needs to be listed at https://github.com/FreeCAD/FreeCAD-addons/blob/master/ALLOWED_PYTHON_PACKAGES.txt? => already listed there, sorry for the noise

@APEbbers
Copy link
Owner

APEbbers commented Mar 9, 2024

Hi,

I've removed the dependency for openpyxl. I've made it an optional library for now and the current version of the WB doesn't need it. If you update to version 0.0.5.9, the problem should be fixed.

So for now the issue is solved. However in the future this problem might occur again. The problems are related to the image systems in Linux. specificly snap and flatpack. These images needs a manual install for any python package that is not standard shipped with FreeCAD

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants