Porting to python3
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
Re: Porting to python3
This looks like a graphics driver issue (all the screen seems "shifted" up or redrawn "below" the window title bar)...
Re: Porting to python3
It's never to late ... Just wanted to tell you guys that I eventually joined the Py3 Party on ALLk my systems, the work machine and the developing and testing machine It is much easier not to wait for Travis to see if a patch is fine because I had no Py3 dev machine ...
It is my own chistmas present. But took me nearly one day.
It is my own chistmas present. But took me nearly one day.
Re: Porting to python3
Good to hear that. Just don't forget and to start introducing Python 2 issues now!
Re: Porting to python3
The issue is related to openpyxl import. More specifically, you will need to start PipTools and in addition install lxml package.ebrahim raeyat wrote: ↑Tue Dec 11, 2018 9:02 pm yes. in interactive python consol in FreeCAD type this:
Code: Select all
import pandas as pd df = pd.DataFrame() df.to_excel('/home/ebi/df1.xlsx')
Happy Coding!
Re: Porting to python3
Are you guys aware of this? Got this error first time testing a macOS py3 build:
Code: Select all
memoryview: a bytes-like object is required, not 'str'
Traceback (most recent call last):
File "<string>", line 66, in Initialize
File "/Users/peter/FreeCAD/install/FreeCAD.app/Contents/Mod/OpenSCAD/OpenSCADUtils.py", line 78, in searchforopenscadexe
stdout,stderr = p1.communicate(ascript)
File "/Users/peter/FreeCAD/install/FreeCAD.app/Contents/lib/python3.6/subprocess.py", line 843, in communicate
stdout, stderr = self._communicate(input, endtime, timeout)
File "/Users/peter/FreeCAD/install/FreeCAD.app/Contents/lib/python3.6/subprocess.py", line 1499, in _communicate
input_view = memoryview(self._input)
Re: Porting to python3
No problem on Windows or Linux. Obviously the function communicate expects bytes instead of str objects. Can you test if replacingpeterl94 wrote: ↑Wed Jan 02, 2019 6:12 am Are you guys aware of this? Got this error first time testing a macOS py3 build:Code: Select all
memoryview: a bytes-like object is required, not 'str' Traceback (most recent call last): File "<string>", line 66, in Initialize File "/Users/peter/FreeCAD/install/FreeCAD.app/Contents/Mod/OpenSCAD/OpenSCADUtils.py", line 78, in searchforopenscadexe stdout,stderr = p1.communicate(ascript) File "/Users/peter/FreeCAD/install/FreeCAD.app/Contents/lib/python3.6/subprocess.py", line 843, in communicate stdout, stderr = self._communicate(input, endtime, timeout) File "/Users/peter/FreeCAD/install/FreeCAD.app/Contents/lib/python3.6/subprocess.py", line 1499, in _communicate input_view = memoryview(self._input)
Code: Select all
ascript = ('tell application "Finder"\n'
'POSIX path of (application file id "org.openscad.OpenSCAD"'
'as alias)\n'
'end tell')
Code: Select all
ascript = (b'tell application "Finder"\n'
'POSIX path of (application file id "org.openscad.OpenSCAD"'
'as alias)\n'
'end tell')
Re: Porting to python3
Thanks, that did fix it.
There is one more:
Code: Select all
Traceback (most recent call last):
File "/Users/peter/FreeCAD/install/FreeCAD.app/Contents/lib/python3.6/unittest/case.py", line 59, in testPartExecutor
yield
File "/Users/peter/FreeCAD/install/FreeCAD.app/Contents/lib/python3.6/unittest/case.py", line 605, in run
testMethod()
File "/Users/peter/FreeCAD/install/FreeCAD.app/Contents/Mod/Test/TestPythonSyntax.py", line 44, in testAll
test_python_syntax(mod_dir, self.whitelist)
File "/Users/peter/FreeCAD/install/FreeCAD.app/Contents/Mod/Test/TestPythonSyntax.py", line 19, in test_python_syntax
ast.parse(py_file.read())
File "/Users/peter/FreeCAD/install/FreeCAD.app/Contents/lib/python3.6/encodings/ascii.py", line 26, in decode
return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 204: ordinal not in range(128)
Re: Porting to python3
I don't know what exactly the problem is. py_file is opened with encoding=utf-8 but maybe ast.parse fails. Any idea for which input file it fails?
Re: Porting to python3
Found the problem. Not sure why it is not a problem for other platforms.
Code: Select all
diff --git a/src/Mod/Test/TestPythonSyntax.py b/src/Mod/Test/TestPythonSyntax.py
index f529c5e78..f30536689 100644
--- a/src/Mod/Test/TestPythonSyntax.py
+++ b/src/Mod/Test/TestPythonSyntax.py
@@ -11,7 +11,7 @@ def test_python_syntax(rootdir, whitelist=None):
for sub_dir, dirs, files in os.walk(rootdir):
for fn in files:
kargs = {}
- if sys.version_info.major > 3:
+ if sys.version_info.major >= 3:
kargs["encoding"] = "utf-8"
if (not fn in whitelist) and os.path.splitext(fn)[1] == '.py':
with open(os.path.join(sub_dir, fn), **kargs) as py_file:
Re: Porting to python3
Good catch! Just overlooked the ">". But no idea why there is no problem on other platforms.Found the problem. Not sure why it is not a problem for other platforms.