[GRASS-dev] experimental Python 3 support in trunk

Hi,

I committed the experimental support of Python 3 to trunk (grass77) by Sanjeet (GSoC 2018). In the first stage of testing, we need to make sure GRASS can compile and run with Python 2 without problems. Python 3 support is highly experimental, we are still having problems with ctypes and libraries using them. However, you should be able to compile GRASS, launch GUI and run modules. I tested it on Ubuntu 16.04 with Python 2.7 and Python 3.5 (virtualenv), utf8 English locale, other platforms were not tested.

For reporting bugs related to this, please create tickets and put ‘Python3’ as keyword (even for problems running GRASS on Python2 related to this commit).

Anna

On Mon, Sep 3, 2018 at 4:21 AM Anna Petrášová <kratochanna@gmail.com> wrote:

Hi,

I committed the experimental support of Python 3 to trunk (grass77) by Sanjeet (GSoC 2018).

This is excellent, thanks for much for your hard work, Sanjeet, Anna
and all involved!

In the first stage of testing, we need to make sure GRASS can compile and run with Python 2 without problems. Python 3 support is highly experimental, we are still having problems with ctypes and libraries using them. However, you should be able to compile GRASS, launch GUI and run modules. I tested it on Ubuntu 16.04 with Python 2.7 and Python 3.5 (virtualenv), utf8 English locale, other platforms were not tested.

Could you please post a few lines how to properly do the testing with
virtualenv?

For reporting bugs related to this, please create tickets and put 'Python3' as keyword (even for problems running GRASS on Python2 related to this commit).

Anna

thanks again,
Markus

Le Mon, 3 Sep 2018 08:27:53 +0200,
Markus Neteler <neteler@osgeo.org> a écrit :

On Mon, Sep 3, 2018 at 4:21 AM Anna Petrášová <kratochanna@gmail.com>
wrote:
>
> Hi,
>
> I committed the experimental support of Python 3 to trunk (grass77)
> by Sanjeet (GSoC 2018).

This is excellent, thanks for much for your hard work, Sanjeet, Anna
and all involved!

+1

This is a great step forward. Many thanks !

Moritz

On Mon, Sep 3, 2018 at 2:28 AM Markus Neteler <neteler@osgeo.org> wrote:

On Mon, Sep 3, 2018 at 4:21 AM Anna Petrášová <kratochanna@gmail.com> wrote:

Hi,

I committed the experimental support of Python 3 to trunk (grass77) by Sanjeet (GSoC 2018).

This is excellent, thanks for much for your hard work, Sanjeet, Anna
and all involved!

In the first stage of testing, we need to make sure GRASS can compile and run with Python 2 without problems. Python 3 support is highly experimental, we are still having problems with ctypes and libraries using them. However, you should be able to compile GRASS, launch GUI and run modules. I tested it on Ubuntu 16.04 with Python 2.7 and Python 3.5 (virtualenv), utf8 English locale, other platforms were not tested.

Could you please post a few lines how to properly do the testing with
virtualenv?

https://trac.osgeo.org/grass/wiki/Python3Support#Howtotest

also, we have now new small dependency - Python ‘six’ package

For reporting bugs related to this, please create tickets and put ‘Python3’ as keyword (even for problems running GRASS on Python2 related to this commit).

Anna

thanks again,
Markus

Anna Petrášová wrote

https://trac.osgeo.org/grass/wiki/Python3Support#Howtotest

also, we have now new small dependency - Python 'six' package

updated the winGRASS compiling guidelines regarding python3 and six.

[1] https://trac.osgeo.org/grass/wiki/CompileOnWindows

-----
best regards
Helmut
--
Sent from: http://osgeo-org.1560.x6.nabble.com/Grass-Dev-f3991897.html

Hi,

po 3. 9. 2018 v 15:48 odesílatel Anna Petrášová <kratochanna@gmail.com> napsal:

> I committed the experimental support of Python 3 to trunk (grass77) by Sanjeet (GSoC 2018).

great, thanks for hard work! Python3 support will be crucial for GRASS
in a near feature. Will help with testing. Martin

--
Martin Landa
http://geo.fsv.cvut.cz/gwiki/Landa
http://gismentors.cz/mentors/landa

On Mon, Sep 3, 2018 at 3:48 PM Anna Petrášová <kratochanna@gmail.com> wrote:

On Mon, Sep 3, 2018 at 2:28 AM Markus Neteler <neteler@osgeo.org> wrote:

...

Could you please post a few lines how to properly do the testing with
virtualenv?

https://trac.osgeo.org/grass/wiki/Python3Support#Howtotest

Thanks.
I took liberty to expand that section a bit (a bit more text; and with
hints for Fedora users as well).

also, we have now new small dependency - Python 'six' package

ok, perhaps to be added in REQUIREMENTS.txt as well?

Markus

Hi,

po 3. 9. 2018 v 20:47 odesílatel Markus Neteler <neteler@osgeo.org> napsal:

my first attempt to start GRASS fails with:

(grasspy3) martin@debian:~/src/grass7_trunk$
./bin.x86_64-pc-linux-gnu/grass77 -text
Traceback (most recent call last):
  File "./bin.x86_64-pc-linux-gnu/grass77", line 2162, in <module>
    main()
  File "./bin.x86_64-pc-linux-gnu/grass77", line 2010, in main
    set_paths(grass_config_dir=grass_config_dir)
  File "./bin.x86_64-pc-linux-gnu/grass77", line 623, in set_paths
    os.environ['MANPATH'] = sys_man_path
  File "/home/martin/Downloads/grasspy3/lib/python3.6/os.py", line
674, in __setitem__
    value = self.encodevalue(value)
  File "/home/martin/Downloads/grasspy3/lib/python3.6/os.py", line
744, in encode
    raise TypeError("str expected, not %s" % type(value).__name__)
TypeError: str expected, not bytes

Is it expected? Ma

--
Martin Landa
http://geo.fsv.cvut.cz/gwiki/Landa
http://gismentors.cz/mentors/landa

Markus Neteler wrote

Could you please post a few lines how to properly do the testing with
virtualenv?

https://trac.osgeo.org/grass/wiki/Python3Support#Howtotest

Thanks.
I took liberty to expand that section a bit (a bit more text; and with
hints for Fedora users as well).

some notes added there how to compile winGRASS in a virtual python 3
environment.

-----
best regards
Helmut
--
Sent from: http://osgeo-org.1560.x6.nabble.com/Grass-Dev-f3991897.html

Hi,
(reducing to grass-dev)

... while I wanted to test, my box fails on "pip install wxpython" in
the virtualenv-3:

pip install wxpython
[...# 30min later: ...]
...
    Finding libs for WXAUI : yes
    'configure' finished successfully (1.340s)
    Waf: Entering directory
`/home/mneteler/tmp/pip-install-mwki9u85/wxpython/build/waf/3.6/gtk3'
    [629/868] Linking
build/waf/3.6/gtk3/_glcanvas.cpython-36m-x86_64-linux-gnu.so
    [630/868] Compiling sip/cpp/sip_html2wxWebViewHistoryItem.cpp
    [631/868] Compiling sip/cpp/sip_html2wxWebViewHandler.cpp
    [632/868] Compiling sip/cpp/sip_html2wxWebViewFactory.cpp
    [633/868] Compiling sip/cpp/sip_html2wxWebViewFSHandler.cpp
    ../../../../sip/cpp/sip_html2wxWebViewHistoryItem.cpp: In function
‘PyObject* meth_wxWebViewHistoryItem_GetUrl(PyObject*, PyObject*)’:
    ../../../../sip/cpp/sip_html2wxWebViewHistoryItem.cpp:24:12:
error: ‘::wxWebViewHistoryItem’ has not been declared
              ::wxWebViewHistoryItem *sipCpp;
                ^~~~~~~~~~~~~~~~~~~~
    ../../../../sip/cpp/sip_html2wxWebViewHistoryItem.cpp:24:12: note:
suggested alternative: ‘sipName_WebViewHistoryItem’
              ::wxWebViewHistoryItem *sipCpp;
....
[... tons of sip errors...]
...
    Waf: Leaving directory
`/home/mneteler/tmp/pip-install-mwki9u85/wxpython/build/waf/3.6/gtk3'
    Build failed
     -> task in '_html2' failed with exit status 1 (run with -v to
display more information)
     -> task in '_html2' failed with exit status 1 (run with -v to
display more information)
     -> task in '_html2' failed with exit status 1 (run with -v to
display more information)
     -> task in '_html2' failed with exit status 1 (run with -v to
display more information)
    Command '"/home/mneteler/grasspy3/bin/python3"
/home/mneteler/tmp/pip-install-mwki9u85/wxpython/bin/waf-2.0.7
--wx_config=/home/mneteler/tmp/pip-install-mwki9u85/wxpython/build/wxbld/gtk3/wx-config
--gtk3 --python="/home/mneteler/grasspy3/bin/python3"
--out=build/waf/3.6/gtk3 configure build ' failed with exit code 1.
    Finished command: build_py (0m8.387s)
    Finished command: build (0m9.512s)
    Command '"/home/mneteler/grasspy3/bin/python3" -u build.py build'
failed with exit code 1.

    ----------------------------------------
Command "/home/mneteler/grasspy3/bin/python3 -u -c "import setuptools,
tokenize;__file__='/home/mneteler/tmp/pip-install-mwki9u85/wxpython/setup.py';f=getattr(tokenize,
'open', open)(__file__);code=f.read().replace('\r\n',
'\n');f.close();exec(compile(code, __file__, 'exec'))" install
--record /home/mneteler/tmp/pip-record-sdim1_xp/install-record.txt
--single-version-externally-managed --compile --install-headers
/home/mneteler/grasspy3/include/site/python3.6/wxpython" failed with
error code 1 in /home/mneteler/tmp/pip-install-mwki9u85/wxpython/

Any idea?

When simply ignoring the GUI for now:

(grasspy3) [mneteler@oboe ~ ]$ python3 ~/bin/grass76
Traceback (most recent call last):
  File "/home/mneteler/bin/grass76", line 2162, in <module>
    main()
  File "/home/mneteler/bin/grass76", line 2010, in main
    set_paths(grass_config_dir=grass_config_dir)
  File "/home/mneteler/bin/grass76", line 623, in set_paths
    os.environ['MANPATH'] = sys_man_path
  File "/home/mneteler/grasspy3/lib64/python3.6/os.py", line 674, in __setitem__
    value = self.encodevalue(value)
  File "/home/mneteler/grasspy3/lib64/python3.6/os.py", line 744, in encode
    raise TypeError("str expected, not %s" % type(value).__name__)
TypeError: str expected, not bytes

(same error as Martin)

Markus

On Mon, Sep 3, 2018 at 4:48 PM Markus Neteler <neteler@osgeo.org> wrote:

Hi,
(reducing to grass-dev)

… while I wanted to test, my box fails on “pip install wxpython” in
the virtualenv-3:

pip install wxpython
[…# 30min later: …]

Finding libs for WXAUI : yes
‘configure’ finished successfully (1.340s)
Waf: Entering directory
/home/mneteler/tmp/pip-install-mwki9u85/wxpython/build/waf/3.6/gtk3' [629/868] Linking build/waf/3.6/gtk3/_[glcanvas.cpython-36m-x86_64-linux-gnu.so](http://glcanvas.cpython-36m-x86_64-linux-gnu.so) [630/868] Compiling sip/cpp/sip_html2wxWebViewHistoryItem.cpp [631/868] Compiling sip/cpp/sip_html2wxWebViewHandler.cpp [632/868] Compiling sip/cpp/sip_html2wxWebViewFactory.cpp [633/868] Compiling sip/cpp/sip_html2wxWebViewFSHandler.cpp ../../../../sip/cpp/sip_html2wxWebViewHistoryItem.cpp: In function ‘PyObject* meth_wxWebViewHistoryItem_GetUrl(PyObject*, PyObject*)’: ../../../../sip/cpp/sip_html2wxWebViewHistoryItem.cpp:24:12: error: ‘::wxWebViewHistoryItem’ has not been declared ::wxWebViewHistoryItem *sipCpp; ^~~~~~~~~~~~~~~~~~~~ ../../../../sip/cpp/sip_html2wxWebViewHistoryItem.cpp:24:12: note: suggested alternative: ‘sipName_WebViewHistoryItem’ ::wxWebViewHistoryItem *sipCpp; .... [... tons of sip errors...] ... Waf: Leaving directory /home/mneteler/tmp/pip-install-mwki9u85/wxpython/build/waf/3.6/gtk3’
Build failed
→ task in ‘_html2’ failed with exit status 1 (run with -v to
display more information)
→ task in ‘_html2’ failed with exit status 1 (run with -v to
display more information)
→ task in ‘_html2’ failed with exit status 1 (run with -v to
display more information)
→ task in ‘_html2’ failed with exit status 1 (run with -v to
display more information)
Command '“/home/mneteler/grasspy3/bin/python3”
/home/mneteler/tmp/pip-install-mwki9u85/wxpython/bin/waf-2.0.7
–wx_config=/home/mneteler/tmp/pip-install-mwki9u85/wxpython/build/wxbld/gtk3/wx-config
–gtk3 --python=“/home/mneteler/grasspy3/bin/python3”
–out=build/waf/3.6/gtk3 configure build ’ failed with exit code 1.
Finished command: build_py (0m8.387s)
Finished command: build (0m9.512s)
Command ‘“/home/mneteler/grasspy3/bin/python3” -u build.py build’
failed with exit code 1.


Command “/home/mneteler/grasspy3/bin/python3 -u -c “import setuptools,
tokenize;file=‘/home/mneteler/tmp/pip-install-mwki9u85/wxpython/setup.py’;f=getattr(tokenize,
‘open’, open)(file);code=f.read().replace(‘\r\n’,
‘\n’);f.close();exec(compile(code, file, ‘exec’))” install
–record /home/mneteler/tmp/pip-record-sdim1_xp/install-record.txt
–single-version-externally-managed --compile --install-headers
/home/mneteler/grasspy3/include/site/python3.6/wxpython” failed with
error code 1 in /home/mneteler/tmp/pip-install-mwki9u85/wxpython/

Any idea?

it looks like it’s missing a package, on ubuntu it’s libwebkit-dev

When simply ignoring the GUI for now:

(grasspy3) [mneteler@oboe ~ ]$ python3 ~/bin/grass76
Traceback (most recent call last):
File “/home/mneteler/bin/grass76”, line 2162, in
main()
File “/home/mneteler/bin/grass76”, line 2010, in main
set_paths(grass_config_dir=grass_config_dir)
File “/home/mneteler/bin/grass76”, line 623, in set_paths
os.environ[‘MANPATH’] = sys_man_path
File “/home/mneteler/grasspy3/lib64/python3.6/os.py”, line 674, in setitem
value = self.encodevalue(value)
File “/home/mneteler/grasspy3/lib64/python3.6/os.py”, line 744, in encode
raise TypeError(“str expected, not %s” % type(value).name)
TypeError: str expected, not bytes

(same error as Martin)

working on it, I don’t get this because of some settings in my environment, which don’t get to that line causing the error

Markus

On Mon, Sep 3, 2018 at 4:56 PM Anna Petrášová <kratochanna@gmail.com> wrote:

On Mon, Sep 3, 2018 at 4:48 PM Markus Neteler <neteler@osgeo.org> wrote:

Hi,
(reducing to grass-dev)

… while I wanted to test, my box fails on “pip install wxpython” in
the virtualenv-3:

pip install wxpython
[…# 30min later: …]

Finding libs for WXAUI : yes
‘configure’ finished successfully (1.340s)
Waf: Entering directory
/home/mneteler/tmp/pip-install-mwki9u85/wxpython/build/waf/3.6/gtk3' [629/868] Linking build/waf/3.6/gtk3/_[glcanvas.cpython-36m-x86_64-linux-gnu.so](http://glcanvas.cpython-36m-x86_64-linux-gnu.so) [630/868] Compiling sip/cpp/sip_html2wxWebViewHistoryItem.cpp [631/868] Compiling sip/cpp/sip_html2wxWebViewHandler.cpp [632/868] Compiling sip/cpp/sip_html2wxWebViewFactory.cpp [633/868] Compiling sip/cpp/sip_html2wxWebViewFSHandler.cpp ../../../../sip/cpp/sip_html2wxWebViewHistoryItem.cpp: In function ‘PyObject* meth_wxWebViewHistoryItem_GetUrl(PyObject*, PyObject*)’: ../../../../sip/cpp/sip_html2wxWebViewHistoryItem.cpp:24:12: error: ‘::wxWebViewHistoryItem’ has not been declared ::wxWebViewHistoryItem *sipCpp; ^~~~~~~~~~~~~~~~~~~~ ../../../../sip/cpp/sip_html2wxWebViewHistoryItem.cpp:24:12: note: suggested alternative: ‘sipName_WebViewHistoryItem’ ::wxWebViewHistoryItem *sipCpp; .... [... tons of sip errors...] ... Waf: Leaving directory /home/mneteler/tmp/pip-install-mwki9u85/wxpython/build/waf/3.6/gtk3’
Build failed
→ task in ‘_html2’ failed with exit status 1 (run with -v to
display more information)
→ task in ‘_html2’ failed with exit status 1 (run with -v to
display more information)
→ task in ‘_html2’ failed with exit status 1 (run with -v to
display more information)
→ task in ‘_html2’ failed with exit status 1 (run with -v to
display more information)
Command '“/home/mneteler/grasspy3/bin/python3”
/home/mneteler/tmp/pip-install-mwki9u85/wxpython/bin/waf-2.0.7
–wx_config=/home/mneteler/tmp/pip-install-mwki9u85/wxpython/build/wxbld/gtk3/wx-config
–gtk3 --python=“/home/mneteler/grasspy3/bin/python3”
–out=build/waf/3.6/gtk3 configure build ’ failed with exit code 1.
Finished command: build_py (0m8.387s)
Finished command: build (0m9.512s)
Command ‘“/home/mneteler/grasspy3/bin/python3” -u build.py build’
failed with exit code 1.


Command “/home/mneteler/grasspy3/bin/python3 -u -c “import setuptools,
tokenize;file=‘/home/mneteler/tmp/pip-install-mwki9u85/wxpython/setup.py’;f=getattr(tokenize,
‘open’, open)(file);code=f.read().replace(‘\r\n’,
‘\n’);f.close();exec(compile(code, file, ‘exec’))” install
–record /home/mneteler/tmp/pip-record-sdim1_xp/install-record.txt
–single-version-externally-managed --compile --install-headers
/home/mneteler/grasspy3/include/site/python3.6/wxpython” failed with
error code 1 in /home/mneteler/tmp/pip-install-mwki9u85/wxpython/

Any idea?

it looks like it’s missing a package, on ubuntu it’s libwebkit-dev

When simply ignoring the GUI for now:

(grasspy3) [mneteler@oboe ~ ]$ python3 ~/bin/grass76
Traceback (most recent call last):
File “/home/mneteler/bin/grass76”, line 2162, in
main()
File “/home/mneteler/bin/grass76”, line 2010, in main
set_paths(grass_config_dir=grass_config_dir)
File “/home/mneteler/bin/grass76”, line 623, in set_paths
os.environ[‘MANPATH’] = sys_man_path
File “/home/mneteler/grasspy3/lib64/python3.6/os.py”, line 674, in setitem
value = self.encodevalue(value)
File “/home/mneteler/grasspy3/lib64/python3.6/os.py”, line 744, in encode
raise TypeError(“str expected, not %s” % type(value).name)
TypeError: str expected, not bytes

(same error as Martin)

working on it, I don’t get this because of some settings in my environment, which don’t get to that line causing the error

Try r73241

Markus

Helmut Kudrnovsky wrote

Markus Neteler wrote

Could you please post a few lines how to properly do the testing with
virtualenv?

https://trac.osgeo.org/grass/wiki/Python3Support#Howtotest

Thanks.
I took liberty to expand that section a bit (a bit more text; and with
hints for Fedora users as well).

some notes added there how to compile winGRASS in a virtual python 3
environment.

compiling winGRASS-python3 along this notes [but forgotten to do svn up
;-)]; with this old svn status, compilation

------------------------------------------
test@DESKTOP-VADT8Q4 MINGW64 /usr/src/grasspy3/grass_trunk
$ PACKAGE_POSTFIX=-daily OSGEO4W_POSTFIX=64 ./mswindows/osgeo4w/package.sh
GRASS GIS 7.7.svn r73230M compilation log
--------------------------------------------------
Started compilation: Mon Sep 3 21:01:57 CEST 2018
--
Errors in:
/usr/src/grasspy3/grass_trunk/lib/python/ctypes
--
In case of errors please change into the directory with error and run
'make'.
If you get multiple errors, you need to deal with them in the order they
appear in the error log. If you get an error building a library, you will
also get errors from anything which uses the library.
--
Finished compilation: Mon Sep 3 21:58:44 CEST 2018
(grasspy3)
------------------------------------------

switching to the related directory

------------------------------------------
test@DESKTOP-VADT8Q4 MINGW64 /usr/src/grasspy3/grass_trunk
$ cd lib/python/ctypes
(grasspy3)
make

make
/usr/src/grasspy3/grass_trunk/dist.x86_64-w64-mingw32/etc/python/grass/lib
make[1]: Entering directory
'/usr/src/grasspy3/grass_trunk/lib/python/ctypes'
make[1]:
'/usr/src/grasspy3/grass_trunk/dist.x86_64-w64-mingw32/etc/python/grass/lib'
is up to date.
make[1]: Leaving directory '/usr/src/grasspy3/grass_trunk/lib/python/ctypes'
make OBJ.x86_64-w64-mingw32/date.py OBJ.x86_64-w64-mingw32/gis.py
OBJ.x86_64-w64-mingw32/raster.py OBJ.x86_64-w64-mingw32/gmath.py O
[...]
dows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0/:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl
" LC_ALL=C LANG=C LANGUAGE=C ./ctypesgen.py --cpp "gcc -E
-I/c/OSGeo4W64/include -D_FILE_OFFSET_BITS=64 -I/usr/src/grasspy3/gras
s_trunk/dist.x86_64-w64-mingw32/include
-I/usr/src/grasspy3/grass_trunk/dist.x86_64-w64-mingw32/include
-D__GLIBC_HAVE_LONG_LONG" -l
grass_gis.7.7.svn -lintl-8
/usr/src/grasspy3/grass_trunk/dist.x86_64-w64-mingw32/include/grass/gis.h
/usr/src/grasspy3/grass_trunk
/dist.x86_64-w64-mingw32/include/grass/defs/gis.h
/usr/src/grasspy3/grass_trunk/dist.x86_64-w64-mingw32/include/grass/colors.h
/usr/
src/grasspy3/grass_trunk/dist.x86_64-w64-mingw32/include/grass/defs/colors.h
-o OBJ.x86_64-w64-mingw32/gis.py
Traceback (most recent call last):
  File "./ctypesgen.py", line 15, in <module>
    import optparse
ModuleNotFoundError: No module named 'optparse'
make[1]: *** [Makefile:102: OBJ.x86_64-w64-mingw32/gis.py] Error 1
make[1]: Leaving directory '/usr/src/grasspy3/grass_trunk/lib/python/ctypes'
make: *** [Makefile:81: default] Error 2
(grasspy3)
------------------------------------------

looking at

https://docs.python.org/2/library/optparse.html

15.5. optparse — Parser for command line options

New in version 2.3.

Deprecated since version 2.7: The optparse module is deprecated and will not
be developed further; development will continue with the argparse module.

so it's maybe already fixed; will do a fresh svn checkout and compilation.

no other issues found while compilation of winGRASS and python3

-----
best regards
Helmut
--
Sent from: http://osgeo-org.1560.x6.nabble.com/Grass-Dev-f3991897.html

compiling winGRASS-python3 along this notes [but forgotten to do svn up
;-)]

it seems I did svn up, source status was quite new.

-----
best regards
Helmut
--
Sent from: http://osgeo-org.1560.x6.nabble.com/Grass-Dev-f3991897.html

On Mon, Sep 3, 2018 at 11:15 PM Anna Petrášová <kratochanna@gmail.com> wrote:

On Mon, Sep 3, 2018 at 4:56 PM Anna Petrášová <kratochanna@gmail.com> wrote:

On Mon, Sep 3, 2018 at 4:48 PM Markus Neteler <neteler@osgeo.org> wrote:

...

(grasspy3) [mneteler@oboe ~ ]$ python3 ~/bin/grass76
Traceback (most recent call last):
  File "/home/mneteler/bin/grass76", line 2162, in <module>
    main()
  File "/home/mneteler/bin/grass76", line 2010, in main
    set_paths(grass_config_dir=grass_config_dir)
  File "/home/mneteler/bin/grass76", line 623, in set_paths
    os.environ['MANPATH'] = sys_man_path
  File "/home/mneteler/grasspy3/lib64/python3.6/os.py", line 674, in __setitem__
    value = self.encodevalue(value)
  File "/home/mneteler/grasspy3/lib64/python3.6/os.py", line 744, in encode
    raise TypeError("str expected, not %s" % type(value).__name__)
TypeError: str expected, not bytes

(same error as Martin)

working on it, I don't get this because of some settings in my environment, which don't get to that line causing the error

Try r73241

Works!

GRASS 7.7.svn (nc_spm_08_grass7):~ > python --version
Python 3.6.6

thanks,
Markus

On Mon, Sep 3, 2018 at 5:29 PM Helmut Kudrnovsky <hellik@web.de> wrote:

Helmut Kudrnovsky wrote

Markus Neteler wrote

Could you please post a few lines how to properly do the testing with
virtualenv?

https://trac.osgeo.org/grass/wiki/Python3Support#Howtotest

Thanks.
I took liberty to expand that section a bit (a bit more text; and with
hints for Fedora users as well).

some notes added there how to compile winGRASS in a virtual python 3
environment.

compiling winGRASS-python3 along this notes [but forgotten to do svn up
;-)]; with this old svn status, compilation


test@DESKTOP-VADT8Q4 MINGW64 /usr/src/grasspy3/grass_trunk
$ PACKAGE_POSTFIX=-daily OSGEO4W_POSTFIX=64 ./mswindows/osgeo4w/package.sh
GRASS GIS 7.7.svn r73230M compilation log

Started compilation: Mon Sep 3 21:01:57 CEST 2018

Errors in:
/usr/src/grasspy3/grass_trunk/lib/python/ctypes

In case of errors please change into the directory with error and run
‘make’.
If you get multiple errors, you need to deal with them in the order they
appear in the error log. If you get an error building a library, you will
also get errors from anything which uses the library.

Finished compilation: Mon Sep 3 21:58:44 CEST 2018
(grasspy3)

switching to the related directory


test@DESKTOP-VADT8Q4 MINGW64 /usr/src/grasspy3/grass_trunk
$ cd lib/python/ctypes
(grasspy3)
make

make
/usr/src/grasspy3/grass_trunk/dist.x86_64-w64-mingw32/etc/python/grass/lib
make[1]: Entering directory
‘/usr/src/grasspy3/grass_trunk/lib/python/ctypes’
make[1]:
‘/usr/src/grasspy3/grass_trunk/dist.x86_64-w64-mingw32/etc/python/grass/lib’
is up to date.
make[1]: Leaving directory ‘/usr/src/grasspy3/grass_trunk/lib/python/ctypes’
make OBJ.x86_64-w64-mingw32/date.py OBJ.x86_64-w64-mingw32/gis.py
OBJ.x86_64-w64-mingw32/raster.py OBJ.x86_64-w64-mingw32/gmath.py O
[…]
dows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0/:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl
" LC_ALL=C LANG=C LANGUAGE=C ./ctypesgen.py --cpp “gcc -E
-I/c/OSGeo4W64/include -D_FILE_OFFSET_BITS=64 -I/usr/src/grasspy3/gras
s_trunk/dist.x86_64-w64-mingw32/include
-I/usr/src/grasspy3/grass_trunk/dist.x86_64-w64-mingw32/include
-D__GLIBC_HAVE_LONG_LONG” -l
grass_gis.7.7.svn -lintl-8
/usr/src/grasspy3/grass_trunk/dist.x86_64-w64-mingw32/include/grass/gis.h
/usr/src/grasspy3/grass_trunk
/dist.x86_64-w64-mingw32/include/grass/defs/gis.h
/usr/src/grasspy3/grass_trunk/dist.x86_64-w64-mingw32/include/grass/colors.h
/usr/
src/grasspy3/grass_trunk/dist.x86_64-w64-mingw32/include/grass/defs/colors.h
-o OBJ.x86_64-w64-mingw32/gis.py
Traceback (most recent call last):
File “./ctypesgen.py”, line 15, in
import optparse
ModuleNotFoundError: No module named ‘optparse’
make[1]: *** [Makefile:102: OBJ.x86_64-w64-mingw32/gis.py] Error 1
make[1]: Leaving directory ‘/usr/src/grasspy3/grass_trunk/lib/python/ctypes’
make: *** [Makefile:81: default] Error 2
(grasspy3)

looking at

https://docs.python.org/2/library/optparse.html

15.5. optparse — Parser for command line options

New in version 2.3.

Deprecated since version 2.7: The optparse module is deprecated and will not
be developed further; development will continue with the argparse module.

Can you add optparse package? It’s weird, it should be part of standard Python library:
https://docs.python.org/3.7/library/optparse.html

so it’s maybe already fixed; will do a fresh svn checkout and compilation.

no other issues found while compilation of winGRASS and python3


best regards
Helmut

Sent from: http://osgeo-org.1560.x6.nabble.com/Grass-Dev-f3991897.html


grass-dev mailing list
grass-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/grass-dev

Can you add optparse package? It's weird, it should be part of >standard

Python library:

https://docs.python.org/3.7/library/optparse.html

Looking at these Docs:

--------
37.1. optparse — Parser for command line options¶
Source code: Lib/optparse.py

Deprecated since version 3.2: The optparse module is deprecated and will not
be developed further; development will continue with the argparse module.
--------

I'll look tomorrow at it

-----
best regards
Helmut
--
Sent from: http://osgeo-org.1560.x6.nabble.com/Grass-Dev-f3991897.html

On Mon, Sep 3, 2018 at 10:56 PM Anna Petrášová <kratochanna@gmail.com> wrote:

On Mon, Sep 3, 2018 at 4:48 PM Markus Neteler <neteler@osgeo.org> wrote:

Hi,
(reducing to grass-dev)

... while I wanted to test, my box fails on "pip install wxpython" in
the virtualenv-3:

pip install wxpython
[...# 30min later: ...]
...
    Finding libs for WXAUI : yes
    'configure' finished successfully (1.340s)
    Waf: Entering directory
`/home/mneteler/tmp/pip-install-mwki9u85/wxpython/build/waf/3.6/gtk3'
    [629/868] Linking
build/waf/3.6/gtk3/_glcanvas.cpython-36m-x86_64-linux-gnu.so
    [630/868] Compiling sip/cpp/sip_html2wxWebViewHistoryItem.cpp
    [631/868] Compiling sip/cpp/sip_html2wxWebViewHandler.cpp
    [632/868] Compiling sip/cpp/sip_html2wxWebViewFactory.cpp
    [633/868] Compiling sip/cpp/sip_html2wxWebViewFSHandler.cpp
    ../../../../sip/cpp/sip_html2wxWebViewHistoryItem.cpp: In function
‘PyObject* meth_wxWebViewHistoryItem_GetUrl(PyObject*, PyObject*)’:
    ../../../../sip/cpp/sip_html2wxWebViewHistoryItem.cpp:24:12:
error: ‘::wxWebViewHistoryItem’ has not been declared
              ::wxWebViewHistoryItem *sipCpp;
                ^~~~~~~~~~~~~~~~~~~~
    ../../../../sip/cpp/sip_html2wxWebViewHistoryItem.cpp:24:12: note:
suggested alternative: ‘sipName_WebViewHistoryItem’
              ::wxWebViewHistoryItem *sipCpp;
....
[... tons of sip errors...]
...
    Waf: Leaving directory
`/home/mneteler/tmp/pip-install-mwki9u85/wxpython/build/waf/3.6/gtk3'
    Build failed
     -> task in '_html2' failed with exit status 1 (run with -v to
display more information)
     -> task in '_html2' failed with exit status 1 (run with -v to
display more information)
     -> task in '_html2' failed with exit status 1 (run with -v to
display more information)
     -> task in '_html2' failed with exit status 1 (run with -v to
display more information)
    Command '"/home/mneteler/grasspy3/bin/python3"
/home/mneteler/tmp/pip-install-mwki9u85/wxpython/bin/waf-2.0.7
--wx_config=/home/mneteler/tmp/pip-install-mwki9u85/wxpython/build/wxbld/gtk3/wx-config
--gtk3 --python="/home/mneteler/grasspy3/bin/python3"
--out=build/waf/3.6/gtk3 configure build ' failed with exit code 1.
    Finished command: build_py (0m8.387s)
    Finished command: build (0m9.512s)
    Command '"/home/mneteler/grasspy3/bin/python3" -u build.py build'
failed with exit code 1.

    ----------------------------------------
Command "/home/mneteler/grasspy3/bin/python3 -u -c "import setuptools,
tokenize;__file__='/home/mneteler/tmp/pip-install-mwki9u85/wxpython/setup.py';f=getattr(tokenize,
'open', open)(__file__);code=f.read().replace('\r\n',
'\n');f.close();exec(compile(code, __file__, 'exec'))" install
--record /home/mneteler/tmp/pip-record-sdim1_xp/install-record.txt
--single-version-externally-managed --compile --install-headers
/home/mneteler/grasspy3/include/site/python3.6/wxpython" failed with
error code 1 in /home/mneteler/tmp/pip-install-mwki9u85/wxpython/

Any idea?

it looks like it's missing a package, on ubuntu it's libwebkit-dev

Thanks, that is on Fedora:
webkit2gtk3-devel

Now I got also wxpython compiled (30min of compilation on my laptop).

Now the wxGUI start screen comes up.
Once in the session, this error appears:

GRASS 7.7.svn (nc_spm_08_grass7):~ > 00:29:58: Debug: Adding duplicate
image handler for 'Windows bitmap file'
00:29:58: Debug: Adding duplicate image handler for 'Windows bitmap file'
Traceback (most recent call last):
  File "/home/mneteler/software/grass77/dist.x86_64-pc-linux-gnu/gui/wxpython/wxgui.py",
line 101, in OnInit
    from lmgr.frame import GMFrame
  File "/home/mneteler/software/grass77/dist.x86_64-pc-linux-gnu/gui/wxpython/lmgr/frame.py",
line 50, in <module>
    from lmgr.layertree import LayerTree, LMIcons
  File "/home/mneteler/software/grass77/dist.x86_64-pc-linux-gnu/gui/wxpython/lmgr/layertree.py",
line 38, in <module>
    from mapdisp.frame import MapFrame
  File "/home/mneteler/software/grass77/dist.x86_64-pc-linux-gnu/gui/wxpython/mapdisp/frame.py",
line 43, in <module>
    from mapwin.buffered import BufferedMapWindow
  File "/home/mneteler/software/grass77/dist.x86_64-pc-linux-gnu/gui/wxpython/mapwin/buffered.py",
line 52, in <module>
    import grass.lib.gis as gislib
  File "/home/mneteler/software/grass77/dist.x86_64-pc-linux-gnu/etc/python/grass/lib/gis.py",
line 988, in <module>
    G_asprintf = _variadic_function(_func,_restype,_argtypes)
TypeError: __init__() missing 1 required positional argument: 'errcheck'
OnInit returned false, exiting...
GRASS 7.7.svn (nc_spm_08_grass7):~ >

Markus

On Mon, Sep 3, 2018 at 6:33 PM Markus Neteler <neteler@osgeo.org> wrote:

On Mon, Sep 3, 2018 at 10:56 PM Anna Petrášová <kratochanna@gmail.com> wrote:

On Mon, Sep 3, 2018 at 4:48 PM Markus Neteler <neteler@osgeo.org> wrote:

Hi,
(reducing to grass-dev)

… while I wanted to test, my box fails on “pip install wxpython” in
the virtualenv-3:

pip install wxpython
[…# 30min later: …]

Finding libs for WXAUI : yes
‘configure’ finished successfully (1.340s)
Waf: Entering directory
/home/mneteler/tmp/pip-install-mwki9u85/wxpython/build/waf/3.6/gtk3' [629/868] Linking build/waf/3.6/gtk3/_[glcanvas.cpython-36m-x86_64-linux-gnu.so](http://glcanvas.cpython-36m-x86_64-linux-gnu.so) [630/868] Compiling sip/cpp/sip_html2wxWebViewHistoryItem.cpp [631/868] Compiling sip/cpp/sip_html2wxWebViewHandler.cpp [632/868] Compiling sip/cpp/sip_html2wxWebViewFactory.cpp [633/868] Compiling sip/cpp/sip_html2wxWebViewFSHandler.cpp ../../../../sip/cpp/sip_html2wxWebViewHistoryItem.cpp: In function ‘PyObject* meth_wxWebViewHistoryItem_GetUrl(PyObject*, PyObject*)’: ../../../../sip/cpp/sip_html2wxWebViewHistoryItem.cpp:24:12: error: ‘::wxWebViewHistoryItem’ has not been declared ::wxWebViewHistoryItem *sipCpp; ^~~~~~~~~~~~~~~~~~~~ ../../../../sip/cpp/sip_html2wxWebViewHistoryItem.cpp:24:12: note: suggested alternative: ‘sipName_WebViewHistoryItem’ ::wxWebViewHistoryItem *sipCpp; .... [... tons of sip errors...] ... Waf: Leaving directory /home/mneteler/tmp/pip-install-mwki9u85/wxpython/build/waf/3.6/gtk3’
Build failed
→ task in ‘_html2’ failed with exit status 1 (run with -v to
display more information)
→ task in ‘_html2’ failed with exit status 1 (run with -v to
display more information)
→ task in ‘_html2’ failed with exit status 1 (run with -v to
display more information)
→ task in ‘_html2’ failed with exit status 1 (run with -v to
display more information)
Command '“/home/mneteler/grasspy3/bin/python3”
/home/mneteler/tmp/pip-install-mwki9u85/wxpython/bin/waf-2.0.7
–wx_config=/home/mneteler/tmp/pip-install-mwki9u85/wxpython/build/wxbld/gtk3/wx-config
–gtk3 --python=“/home/mneteler/grasspy3/bin/python3”
–out=build/waf/3.6/gtk3 configure build ’ failed with exit code 1.
Finished command: build_py (0m8.387s)
Finished command: build (0m9.512s)
Command ‘“/home/mneteler/grasspy3/bin/python3” -u build.py build’
failed with exit code 1.


Command “/home/mneteler/grasspy3/bin/python3 -u -c “import setuptools,
tokenize;file=‘/home/mneteler/tmp/pip-install-mwki9u85/wxpython/setup.py’;f=getattr(tokenize,
‘open’, open)(file);code=f.read().replace(‘\r\n’,
‘\n’);f.close();exec(compile(code, file, ‘exec’))” install
–record /home/mneteler/tmp/pip-record-sdim1_xp/install-record.txt
–single-version-externally-managed --compile --install-headers
/home/mneteler/grasspy3/include/site/python3.6/wxpython” failed with
error code 1 in /home/mneteler/tmp/pip-install-mwki9u85/wxpython/

Any idea?

it looks like it’s missing a package, on ubuntu it’s libwebkit-dev

Thanks, that is on Fedora:
webkit2gtk3-devel

Now I got also wxpython compiled (30min of compilation on my laptop).

Now the wxGUI start screen comes up.
Once in the session, this error appears:

GRASS 7.7.svn (nc_spm_08_grass7):~ > 00:29:58: Debug: Adding duplicate
image handler for ‘Windows bitmap file’
00:29:58: Debug: Adding duplicate image handler for ‘Windows bitmap file’
Traceback (most recent call last):
File “/home/mneteler/software/grass77/dist.x86_64-pc-linux-gnu/gui/wxpython/wxgui.py”,
line 101, in OnInit
from lmgr.frame import GMFrame
File “/home/mneteler/software/grass77/dist.x86_64-pc-linux-gnu/gui/wxpython/lmgr/frame.py”,
line 50, in
from lmgr.layertree import LayerTree, LMIcons
File “/home/mneteler/software/grass77/dist.x86_64-pc-linux-gnu/gui/wxpython/lmgr/layertree.py”,
line 38, in
from mapdisp.frame import MapFrame
File “/home/mneteler/software/grass77/dist.x86_64-pc-linux-gnu/gui/wxpython/mapdisp/frame.py”,
line 43, in
from mapwin.buffered import BufferedMapWindow
File “/home/mneteler/software/grass77/dist.x86_64-pc-linux-gnu/gui/wxpython/mapwin/buffered.py”,
line 52, in
import grass.lib.gis as gislib
File “/home/mneteler/software/grass77/dist.x86_64-pc-linux-gnu/etc/python/grass/lib/gis.py”,
line 988, in
G_asprintf = _variadic_function(_func,_restype,_argtypes)
TypeError: init() missing 1 required positional argument: ‘errcheck’
OnInit returned false, exiting…
GRASS 7.7.svn (nc_spm_08_grass7):~ >

are you sure you did make distclean?

Markus

On Tue, Sep 4, 2018 at 12:39 AM Anna Petrášová <kratochanna@gmail.com> wrote:

are you sure you did make distclean?

You are right, solved with that.

Here a few more issues: At wxGUI startup:

### in the terminal:
07:37:09: Debug: Adding duplicate image handler for 'Windows bitmap file'
07:37:09: Debug: Adding duplicate image handler for 'Windows bitmap file'

--> perhaps from an underlying lib?

### in the wxGUI console:

Menu > System info

3D view mode not available
Reason: name 'WindowsError' is not defined
Vector digitizer not available
Reason: name 'WindowsError' is not defined
Note that the wxGUI's vector digitizer is disabled in this
installation. Please keep an eye out for updated versions of
GRASS. In the meantime you can use "v.edit" for non-
interactive editing from the Develop vector map menu.
/home/mneteler/software/grass77/dist.x86_64-pc-linux-
gnu/gui/wxpython/mapwin/buffered.py:406:
wxPyDeprecationWarning: Call to deprecated item. Use
DrawLine instead.
  coords[i][1]))
System Info
Traceback (most recent call last):
  File "/home/mneteler/software/grass77/dist.x86_64-pc-
linux-gnu/gui/wxpython/lmgr/frame.py", line 1259, in
OnSystemInfo

_("Platform"), platform.platform().decode('utf8',
'replace'), osgeo4w),
AttributeError
:
'str' object has no attribute 'decode'

##################################################

display raster > select map > OK button

/home/mneteler/software/grass77/dist.x86_64-pc-linux-
gnu/gui/wxpython/mapwin/buffered.py:406:
wxPyDeprecationWarning: Call to deprecated item. Use
DrawLine instead.
  coords[i][1]))
/home/mneteler/software/grass77/dist.x86_64-pc-linux-
gnu/gui/wxpython/mapwin/buffered.py:406:
wxPyDeprecationWarning: Call to deprecated item. Use
DrawLine instead.
  coords[i][1]))

##################################################
# seen in the terminal:

    from grass.pygrass.vector import VectorTopo
  File "/home/mneteler/software/grass77/dist.x86_64-pc-linux-gnu/etc/python/grass/pygrass/vector/__init__.py",
line 7, in <module>
    import grass.lib.vector as libvect
  File "/home/mneteler/software/grass77/dist.x86_64-pc-linux-gnu/etc/python/grass/lib/vector.py",
line 5863
    PORT_LONG_MAX = 2147483647L
                              ^
SyntaxError: invalid syntax

Markus