Running python mypaint.py fails on importing _mypaintlib

Please fill out the topic template below so we can help you faster.

Description of the Problem, or Question?

After I installed mypaint from the github source, I can successfully run it by running “mypaint” in terminal, but if I go to run it as python mypaint.py or if I try to import specific parts of the lib (say, “from lib import surface”) I get the error below. I got the same problem using version 1.2x as here, but the compat-v1.2.2 branch fixed it there, which makes me think it might be a similar problem, but the SConscript file no longer exists, so I’m not sure how to fix it.

Basic System Details

MyPaint version:

2.0.0-alpha+git.5c64063

Operating System + Version:
Ubuntu 16.04.5

Using anaconda python 3.7.4

Please Tell Us How to Reproduce the Problem in Steps.

  1. Install mypaintbrushes and libmypaint
  2. download mypaint,
    run:
python setup.py managed_install
sudo ldconfig
python mypaint.py

or after installation in the mypaint folder:

python
import lib.surface

Are there any Errors Popping Up? If so, paste the text in the area shown below.

(I replaced my username with ‘user’ here in /home/user/~)

Traceback (most recent call last):
  File "/home/user/Documents/paint/3/mypaint/lib/mypaintlib.py", line 18, in swig_import_helper
    fp, pathname, description = imp.find_module('_mypaintlib', [dirname(__file__)])
  File "/home/user/anaconda3/envs/paint3/lib/python3.7/imp.py", line 296, in find_module
    raise ImportError(_ERR_MSG.format(name), name=name)
ImportError: No module named '_mypaintlib'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "mypaint.py", line 464, in <module>
    = get_paths()
  File "mypaint.py", line 230, in get_paths
    from lib import fileutils
  File "/home/user/Documents/paint/3/mypaint/lib/fileutils.py", line 26, in <module>
    import lib.helpers
  File "/home/user/Documents/paint/3/mypaint/lib/helpers.py", line 26, in <module>
    from . import mypaintlib
  File "/home/user/Documents/paint/3/mypaint/lib/mypaintlib.py", line 28, in <module>
    _mypaintlib = swig_import_helper()
  File "/home/user/Documents/paint/3/mypaint/lib/mypaintlib.py", line 20, in swig_import_helper
    import _mypaintlib
ModuleNotFoundError: No module named '_mypaintlib'

If you want to run from the source directory, you can either use python setup.py demo or copy the _mypaintlib.so file from the build output directory to the lib folder.

_mypaintlib.so will be located in: source_root/build/lib.python-version.stuff/lib/ after a successful build.

1 Like

I ended up making a symlink to the

source_root /build/lib. python-version.stuff /lib/ folder

which seems to be working, thank you very much for your help!