[Solved] IDF import: error import "<class 'ModuleNotFoundError'>: No module named '__builtin__'

Forum per le domande e le discussioni in Italiano
Forum rules
regole del forum e le informazioni utili

Importante: PRIMA di chiedere aiuto leggete qui!
fiffo
Posts: 42
Joined: Wed Oct 18, 2017 8:57 am

[Solved] IDF import: error import "<class 'ModuleNotFoundError'>: No module named '__builtin__'

Postby fiffo » Wed Jun 12, 2019 10:55 am

Ciao a tutti,
provo ad importare un file IDF (.emn file) ma mi compare questo errore... come se mancasse il modulo "builtin" ...
qualcuno mi può aiutare?

"Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\floriano\Desktop\freecad\FreeCAD_0.19.16944_x64_LP_12.1.2_PY3QT5-WinVS2015\FreeCAD_0.19.16944_x64_LP_12.1.2_PY3QT5-WinVS2015\Mod\Idf\Idf.py", line 25, in <module>
import FreeCAD, Part, os, FreeCADGui, __builtin__
<class 'ModuleNotFoundError'>: No module named '__builtin__' "

I used this version of Freecad = 0.19 ...
OS: Windows 10 (10.0)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.16945 (Git)
Build type: Release
Branch: master
Hash: d818a9638424a934bd9da74d187a1af4cb773f05
Python version: 3.6.8
Qt version: 5.12.1
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/United States (en_US)
Last edited by Kunda1 on Tue Jun 18, 2019 2:06 pm, edited 1 time in total.
Reason: Added [Solved] to this thread
renatorivo
Posts: 2096
Joined: Tue Feb 21, 2012 8:07 pm
Location: Torino - Italy

Re: IDF import: error import "<class 'ModuleNotFoundError'>: No module named '__builtin__'

Postby renatorivo » Fri Jun 14, 2019 7:20 pm

Ciao.
Il problema è dovuto al passaggio a Python3:
Renamed module __builtin__ to builtins (removing the underscores, adding an ‘s’). The __builtins__ variable found in most global namespaces is unchanged. To modify a builtin, you should use builtins, not __builtins__!
Puoi vedere altro in https://docs.python.org/3.0/whatsnew/3.0.html

Correggendo le righe 25 e 57 di C:\Program Files\FreeCAD 0.18\Mod\Idf\Idf.py, o dove-si-trova il tuo Mod\Idf, dovrebbe funzionare.
fiffo
Posts: 42
Joined: Wed Oct 18, 2017 8:57 am

Re: IDF import: error import "<class 'ModuleNotFoundError'>: No module named '__builtin__'

Postby fiffo » Mon Jun 17, 2019 12:25 pm

Grazie mille per la risposta...
sai per caso come le devo modificare?
renatorivo
Posts: 2096
Joined: Tue Feb 21, 2012 8:07 pm
Location: Torino - Italy

Re: IDF import: error import "<class 'ModuleNotFoundError'>: No module named '__builtin__'

Postby renatorivo » Mon Jun 17, 2019 8:08 pm

riga 25 di Idf.py

Code: Select all

import FreeCAD, Part, os, FreeCADGui, builtins
e poi riga 57

Code: Select all

pythonopen = builtins.open # to distinguish python built-in open function from the one declared here
provato, funziona in
OS: Windows 8.1
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.16117 (Git)
Build type: Release
Branch: releases/FreeCAD-0-18
Hash: dbb4cc6415bac848a294f03b80f65e888d531742
Python version: 3.6.6
Qt version: 5.6.2
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: Italian/Italy (it_IT)
User avatar
easyw-fc
Posts: 2456
Joined: Thu Jul 09, 2015 9:34 am

Re: IDF import: error import "<class 'ModuleNotFoundError'>: No module named '__builtin__'

Postby easyw-fc » Mon Jun 17, 2019 8:29 pm

it could be a Pull Request then :D
fiffo
Posts: 42
Joined: Wed Oct 18, 2017 8:57 am

Re: IDF import: error import "<class 'ModuleNotFoundError'>: No module named '__builtin__'

Postby fiffo » Tue Jun 18, 2019 1:48 pm

Grazie mille Renato.
Avevo postato lo stesso quesito anche nel forum in inglese dove anche là mi avevano risposto.
renatorivo
Posts: 2096
Joined: Tue Feb 21, 2012 8:07 pm
Location: Torino - Italy

Re: [Solved] IDF import: error import "<class 'ModuleNotFoundError'>: No module named '__builtin__'

Postby renatorivo » Tue Jun 18, 2019 7:55 pm

fiffo wrote:
Tue Jun 18, 2019 1:48 pm
Avevo postato lo stesso quesito anche nel forum in inglese dove anche là mi avevano risposto.
Dato che propone una soluzione diversa si può consultare in https://forum.freecadweb.org/viewtopic.php?f=3&t=36983