Snapcraft build error

i am trying to build snap from my code for only test purpose. After running snapcraft command from project directory, i am getting this kind of error…

This snapcraft project does not specify the base keyword, explicitly setting the base keyword enables the latest snapcraft features.
This project is best built on 'Ubuntu 16.04', but is building on a 'Ubuntu 19.04' host.
Read more about bases at https://docs.snapcraft.io/t/base-snaps/11198
Hit http://in.archive.ubuntu.com/ubuntu disco InRelease                                                                                              
Hit http://in.archive.ubuntu.com/ubuntu disco-updates InRelease                                                                                      
Hit http://in.archive.ubuntu.com/ubuntu disco-backports InRelease                                                                                    
Hit http://security.ubuntu.com/ubuntu disco-security InRelease                                                                                       
Fetched 0 B in 0s (0 B/s)                                                                                                                            
Pulling test-app 
Cloning into '/home/matrix11/DeployWorkstation/test-app/parts/test-app/src'...
remote: Enumerating objects: 6, done.
remote: Counting objects: 100% (6/6), done.
remote: Compressing objects: 100% (5/5), done.
remote: Total 6 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (6/6), done.
Fetching and installing pip...
Collecting pip
  Using cached https://files.pythonhosted.org/packages/54/0c/d01aa759fdc501a58f431eb594a17495f15b88da142ce14b5845662c13f3/pip-20.0.2-py2.py3-none-any.whl
  Saved ./parts/test-app/python-packages/pip-20.0.2-py2.py3-none-any.whl
Successfully downloaded pip
Looking in links: /home/matrix11/DeployWorkstation/test-app/parts/test-app/python-packages
Collecting pip
Installing collected packages: pip
Successfully installed pip-20.0.2
Traceback (most recent call last):
  File "/home/matrix11/DeployWorkstation/test-app/parts/test-app/install/usr/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/home/matrix11/DeployWorkstation/test-app/parts/test-app/install/usr/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/matrix11/DeployWorkstation/test-app/parts/test-app/install/lib/python3.7/site-packages/pip/__main__.py", line 16, in <module>
    from pip._internal.cli.main import main as _main  # isort:skip # noqa
  File "/home/matrix11/DeployWorkstation/test-app/parts/test-app/install/lib/python3.7/site-packages/pip/_internal/cli/main.py", line 10, in <module>
    from pip._internal.cli.autocompletion import autocomplete
  File "/home/matrix11/DeployWorkstation/test-app/parts/test-app/install/lib/python3.7/site-packages/pip/_internal/cli/autocompletion.py", line 9, in <module>
    from pip._internal.cli.main_parser import create_main_parser
  File "/home/matrix11/DeployWorkstation/test-app/parts/test-app/install/lib/python3.7/site-packages/pip/_internal/cli/main_parser.py", line 7, in <module>
    from pip._internal.cli import cmdoptions
  File "/home/matrix11/DeployWorkstation/test-app/parts/test-app/install/lib/python3.7/site-packages/pip/_internal/cli/cmdoptions.py", line 19, in <module>
    from distutils.util import strtobool
ModuleNotFoundError: No module named 'distutils.util'
Traceback (most recent call last):
  File "/home/matrix11/DeployWorkstation/test-app/parts/test-app/install/usr/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/home/matrix11/DeployWorkstation/test-app/parts/test-app/install/usr/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/matrix11/DeployWorkstation/test-app/parts/test-app/install/lib/python3.7/site-packages/pip/__main__.py", line 16, in <module>
    from pip._internal.cli.main import main as _main  # isort:skip # noqa
  File "/home/matrix11/DeployWorkstation/test-app/parts/test-app/install/lib/python3.7/site-packages/pip/_internal/cli/main.py", line 10, in <module>
    from pip._internal.cli.autocompletion import autocomplete
  File "/home/matrix11/DeployWorkstation/test-app/parts/test-app/install/lib/python3.7/site-packages/pip/_internal/cli/autocompletion.py", line 9, in <module>
    from pip._internal.cli.main_parser import create_main_parser
  File "/home/matrix11/DeployWorkstation/test-app/parts/test-app/install/lib/python3.7/site-packages/pip/_internal/cli/main_parser.py", line 7, in <module>
    from pip._internal.cli import cmdoptions
  File "/home/matrix11/DeployWorkstation/test-app/parts/test-app/install/lib/python3.7/site-packages/pip/_internal/cli/cmdoptions.py", line 19, in <module>
    from distutils.util import strtobool
ModuleNotFoundError: No module named 'distutils.util'
Sorry, an error occurred in Snapcraft:
Failed to run '/home/matrix11/DeployWorkstation/test-app/parts/test-app/install/usr/bin/python3 -m pip list': Exited with code 1.

currently i’m running ubuntu 19.04 with both python2.7 and python3.7.
the module distutils is installed in both of the python version.

files in my directory (test-app/):
snap/snapcraft.yaml

name: test-app # you probably want to 'snapcraft register <name>'
version: '0.1' # just for humans, typically '1.2+git' or '1.3.2'
summary: test-app snap # 79 char long summary
description: |
  long test-app snap
grade: stable # must be 'stable' to release into candidate/stable channels
confinement: strict # use 'strict' once you have the right plugs and slots

apps:
  test-app:
    command: bin/test-app

parts:
  test-app:
    # See 'snapcraft plugins'
    plugin: python
    source: https://github.com/purvesh-linux11/test-app.git

setup.py

from setuptools import setup

setup(

	name='test-app',
	version='0.1',
	url='<my github url>',
	author='purvesh',
	author_email='<my-email>',
	description='this is sample test app for snap.'

	)

test-app.py (my custom file)

def main():
	args = sys.argv[1]
	print("snapcraft is working. . . . . . . . . . . . .let's start the FUNNNN..!!!",'\n')
	print("greeting my friend, ",args)

if __name__ == '__main__':
    main()

help me out guys…please.

Thanks for Understanding my problem.

you should either build inside a 16.04 lxd container or VM or move the snap to base: core18 and build in an 18.04 container/VM (lxd/multipass … typically the snapcraft snap fires up multipass with the correct release by default for you, not sure why this did not happen here)

2 Likes

thanks brother…it really helps me. i changed my base to core16 and it works. but now, i have another issue.

this is my updated /snap/snapcraft.yaml

name: test-app # you probably want to 'snapcraft register <name>'
base: core16
version: '0.1' # just for humans, typically '1.2+git' or '1.3.2'
summary: test-app snap # 79 char long summary
description: |
  long test-app snap

grade: devel # must be 'stable' to release into candidate/stable channels
confinement: devmode # use 'strict' once you have the right plugs and slots

apps:
  test-app:
    command: bin/test-app

parts:
  test-app:
    # See 'snapcraft plugins'
    plugin: python
    source: https://github.com/purvesh-linux11/test-app.git

after executing snapcraft command, i get an error.

last few lines of bash output is here:

Building test-app 
Looking in links: /root/parts/test-app/python-packages
Processing /root/parts/test-app/build
Building wheels for collected packages: test-app
  Building wheel for test-app (setup.py) ... done
  Created wheel for test-app: filename=test_app-0.1-py3-none-any.whl size=1038 sha256=c6febc7b60f00ee4f460791e5c1210f11658f3060ced24aa5a2ee148d2966ae0
  Stored in directory: /tmp/pip-ephem-wheel-cache-ckcg5sd3/wheels/e7/96/a0/293bc525ac1ef44ac00f7b255723e97159dac1c60417c7969f
Successfully built test-app
Installing collected packages: test-app
Successfully installed test-app-0.1
/root/parts/test-app/install/usr/bin/python3 setup.py --no-user-cfg install --single-version-externally-managed --user --record install.txt
running install
running build
running install_egg_info
running egg_info
creating test_app.egg-info
writing top-level names to test_app.egg-info/top_level.txt
writing dependency_links to test_app.egg-info/dependency_links.txt
writing test_app.egg-info/PKG-INFO
writing manifest file 'test_app.egg-info/SOURCES.txt'
reading manifest file 'test_app.egg-info/SOURCES.txt'
writing manifest file 'test_app.egg-info/SOURCES.txt'
Copying test_app.egg-info to /root/parts/test-app/install/lib/python3.5/site-packages/test_app-0.1-py3.5.egg-info
running install_scripts
writing list of installed files to 'install.txt'
Staging test-app 
Priming test-app 
Unable to determine library dependencies for '/root/prime/usr/lib/python3.5/lib-dynload/mmap.cpython-35m-x86_64-linux-gnu.so'
Unable to determine library dependencies for '/root/prime/lib/x86_64-linux-gnu/libcrypto.so.1.0.0'
Unable to determine library dependencies for '/root/prime/usr/lib/x86_64-linux-gnu/libmpdec.so.2.4.2'
Unable to determine library dependencies for '/root/prime/usr/lib/x86_64-linux-gnu/libexpatw.so.1.6.0'
Unable to determine library dependencies for '/root/prime/usr/lib/python3.5/lib-dynload/ossaudiodev.cpython-35m-x86_64-linux-gnu.so'
Unable to determine library dependencies for '/root/prime/usr/lib/x86_64-linux-gnu/openssl-1.0.0/engines/libcswift.so'
Unable to determine library dependencies for '/root/prime/usr/lib/python3.5/lib-dynload/xxlimited.cpython-35m-x86_64-linux-gnu.so'
Unable to determine library dependencies for '/root/prime/usr/lib/python3.5/lib-dynload/nis.cpython-35m-x86_64-linux-gnu.so'
Unable to determine library dependencies for '/root/prime/lib/x86_64-linux-gnu/libexpat.so.1.6.0'
Unable to determine library dependencies for '/root/prime/usr/lib/x86_64-linux-gnu/openssl-1.0.0/engines/libnuron.so'
Unable to determine library dependencies for '/root/prime/usr/lib/python3.5/lib-dynload/resource.cpython-35m-x86_64-linux-gnu.so'
Unable to determine library dependencies for '/root/prime/usr/lib/python3.5/lib-dynload/_ctypes_test.cpython-35m-x86_64-linux-gnu.so'
Unable to determine library dependencies for '/root/prime/usr/lib/python3.5/lib-dynload/_multiprocessing.cpython-35m-x86_64-linux-gnu.so'
Unable to determine library dependencies for '/root/prime/usr/lib/x86_64-linux-gnu/openssl-1.0.0/engines/lib4758cca.so'
Unable to determine library dependencies for '/root/prime/usr/lib/python3.5/lib-dynload/cmath.cpython-35m-x86_64-linux-gnu.so'
Unable to determine library dependencies for '/root/prime/usr/lib/x86_64-linux-gnu/openssl-1.0.0/engines/libgost.so'
Unable to determine library dependencies for '/root/prime/usr/lib/python3.5/lib-dynload/_testbuffer.cpython-35m-x86_64-linux-gnu.so'
Unable to determine library dependencies for '/root/prime/usr/lib/python3.5/lib-dynload/_codecs_iso2022.cpython-35m-x86_64-linux-gnu.so'
Unable to determine library dependencies for '/root/prime/usr/lib/python3.5/lib-dynload/_codecs_hk.cpython-35m-x86_64-linux-gnu.so'
Unable to determine library dependencies for '/root/prime/usr/lib/python3.5/lib-dynload/_codecs_kr.cpython-35m-x86_64-linux-gnu.so'
Unable to determine library dependencies for '/root/prime/usr/lib/python3.5/lib-dynload/_codecs_tw.cpython-35m-x86_64-linux-gnu.so'
Unable to determine library dependencies for '/root/prime/usr/lib/python3.5/lib-dynload/parser.cpython-35m-x86_64-linux-gnu.so'
Unable to determine library dependencies for '/root/prime/usr/lib/x86_64-linux-gnu/openssl-1.0.0/engines/libpadlock.so'
Unable to determine library dependencies for '/root/prime/usr/lib/python3.5/lib-dynload/_curses_panel.cpython-35m-x86_64-linux-gnu.so'
Unable to determine library dependencies for '/root/prime/usr/lib/python3.5/lib-dynload/_testimportmultiple.cpython-35m-x86_64-linux-gnu.so'
Unable to determine library dependencies for '/root/prime/usr/lib/python3.5/lib-dynload/_csv.cpython-35m-x86_64-linux-gnu.so'
Unable to determine library dependencies for '/root/prime/usr/lib/python3.5/lib-dynload/_hashlib.cpython-35m-x86_64-linux-gnu.so'
Unable to determine library dependencies for '/root/prime/usr/lib/python3.5/lib-dynload/_ssl.cpython-35m-x86_64-linux-gnu.so'
Unable to determine library dependencies for '/root/prime/usr/lib/python3.5/lib-dynload/_crypt.cpython-35m-x86_64-linux-gnu.so'
Unable to determine library dependencies for '/root/prime/lib/x86_64-linux-gnu/libssl.so.1.0.0'
Unable to determine library dependencies for '/root/prime/usr/lib/python3.5/lib-dynload/_codecs_jp.cpython-35m-x86_64-linux-gnu.so'
Unable to determine library dependencies for '/root/prime/usr/lib/x86_64-linux-gnu/openssl-1.0.0/engines/libubsec.so'
Unable to determine library dependencies for '/root/prime/usr/lib/python3.5/lib-dynload/fpectl.cpython-35m-x86_64-linux-gnu.so'
Unable to determine library dependencies for '/root/prime/usr/lib/python3.5/lib-dynload/_testmultiphase.cpython-35m-x86_64-linux-gnu.so'
Unable to determine library dependencies for '/root/prime/usr/lib/python3.5/lib-dynload/_opcode.cpython-35m-x86_64-linux-gnu.so'
Unable to determine library dependencies for '/root/prime/usr/lib/python3.5/lib-dynload/_testcapi.cpython-35m-x86_64-linux-gnu.so'
Unable to determine library dependencies for '/root/prime/usr/lib/x86_64-linux-gnu/openssl-1.0.0/engines/libcapi.so'
Unable to determine library dependencies for '/root/prime/usr/lib/python3.5/lib-dynload/_json.cpython-35m-x86_64-linux-gnu.so'
Unable to determine library dependencies for '/root/prime/usr/lib/x86_64-linux-gnu/libsqlite3.so.0.8.6'
Unable to determine library dependencies for '/root/prime/usr/lib/python3.5/lib-dynload/_codecs_cn.cpython-35m-x86_64-linux-gnu.so'
Unable to determine library dependencies for '/root/prime/usr/lib/python3.5/lib-dynload/_bz2.cpython-35m-x86_64-linux-gnu.so'
Unable to determine library dependencies for '/root/prime/usr/lib/python3.5/lib-dynload/audioop.cpython-35m-x86_64-linux-gnu.so'
Unable to determine library dependencies for '/root/prime/usr/lib/python3.5/lib-dynload/_decimal.cpython-35m-x86_64-linux-gnu.so'
Unable to determine library dependencies for '/root/prime/usr/lib/python3.5/lib-dynload/_curses.cpython-35m-x86_64-linux-gnu.so'
Unable to determine library dependencies for '/root/prime/usr/lib/python3.5/lib-dynload/_dbm.cpython-35m-x86_64-linux-gnu.so'
Unable to determine library dependencies for '/root/prime/usr/lib/python3.5/lib-dynload/_lzma.cpython-35m-x86_64-linux-gnu.so'
Unable to determine library dependencies for '/root/prime/usr/lib/x86_64-linux-gnu/openssl-1.0.0/engines/libgmp.so'
Unable to determine library dependencies for '/root/prime/usr/lib/x86_64-linux-gnu/openssl-1.0.0/engines/libsureware.so'
Unable to determine library dependencies for '/root/prime/usr/lib/x86_64-linux-gnu/openssl-1.0.0/engines/libatalla.so'
Unable to determine library dependencies for '/root/prime/usr/lib/python3.5/lib-dynload/_ctypes.cpython-35m-x86_64-linux-gnu.so'
Unable to determine library dependencies for '/root/prime/usr/lib/python3.5/lib-dynload/termios.cpython-35m-x86_64-linux-gnu.so'
Unable to determine library dependencies for '/root/prime/usr/lib/python3.5/lib-dynload/readline.cpython-35m-x86_64-linux-gnu.so'
Unable to determine library dependencies for '/root/prime/usr/bin/python3.5'
Unable to determine library dependencies for '/root/prime/usr/lib/python3.5/lib-dynload/_multibytecodec.cpython-35m-x86_64-linux-gnu.so'
Unable to determine library dependencies for '/root/prime/usr/lib/python3.5/lib-dynload/_lsprof.cpython-35m-x86_64-linux-gnu.so'
Unable to determine library dependencies for '/root/prime/usr/bin/python3.5m'
Unable to determine library dependencies for '/root/prime/usr/lib/x86_64-linux-gnu/openssl-1.0.0/engines/libaep.so'
Unable to determine library dependencies for '/root/prime/usr/lib/python3.5/lib-dynload/_sqlite3.cpython-35m-x86_64-linux-gnu.so'
Unable to determine library dependencies for '/root/prime/usr/lib/x86_64-linux-gnu/openssl-1.0.0/engines/libchil.so'
Failed to generate snap metadata: The specified command 'bin/test-app' defined in the app 'test-app' is not executable.
Run the same command again with --debug to shell into the environment if you wish to introspect this failure.

can you help again here???

Thanks again…:innocent::+1::+1:

well, make the file executable :slight_smile:

2 Likes

That’s really helps.

my first snap is successfully created. but when i install and try to run it by command: testapp , i get an error log like this,

Traceback (most recent call last):
  File "/snap/testapp/x1/bin/testapp", line 11, in <module>
    load_entry_point('testapp==0.1', 'console_scripts', 'testapp')()
  File "/snap/testapp/x1/lib/python3.5/site-packages/pkg_resources/__init__.py", line 490, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/snap/testapp/x1/lib/python3.5/site-packages/pkg_resources/__init__.py", line 2855, in load_entry_point
    return ep.load()
  File "/snap/testapp/x1/lib/python3.5/site-packages/pkg_resources/__init__.py", line 2446, in load
    return self.resolve()
  File "/snap/testapp/x1/lib/python3.5/site-packages/pkg_resources/__init__.py", line 2452, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
ImportError: No module named 'testapp'

this is my snap/snapcraft.yaml file:

name: testapp # you probably want to 'snapcraft register <name>'
base: core16 # the base snap is the execution environment for this snap
version: '0.1' # just for humans, typically '1.2+git' or '1.3.2'
summary: sample snap # 79 char long summary
description: |
  This is my-snap's description. You have a paragraph or two to tell the
  most important story about your snap. Keep it under 100 words though,
  we live in tweetspace and your description wants to look good in the snap
  store.

grade: devel # must be 'stable' to release into candidate/stable channels
confinement: devmode # use 'strict' once you have the right plugs and slots

apps:
  testapp:
    command: bin/testapp

parts:
  testapp:
    # See 'snapcraft plugins'
    plugin: python
    source: https://github.com/purvesh-linux11/testapp.git

and this is my testapp.py file.(executable python script file).

#!/usr/bin/env python

def main():
	print("snapcraft is working. . . . . . . . . . . . .let's start the FUNNNN..!!!",'\n')
	#print("greeting my friend, ",args)

if __name__ == '__main__':
    main()

this is setup.py file:

from setuptools import setup

setup(

	name='testapp',
	version='0.1',
	url='https://github.com/purvesh-linux11/testapp',
	author='purvesh',
	author_email='<email-here>',
	entry_points={
		'console_scripts':[
			'testapp=testapp:main'
		]
	},
	description='sample test snap'
)

can you guide me through my error and what this error means.

Thanks for helping me here…really appreciate.

try adding something like:

    environment:
      PYTHONPATH: $SNAP/usr/lib/python2.7/site-packages:$SNAP/usr/lib/python2.7/dist-packages:$PYTHONPATH

to your apps: entry so python searches in the right place for your module.

1 Like

hey, i add this environment variable into snapcraft.yaml file and after that i again try to build snap but i got this error.::

Issues while validating snapcraft.yaml: The 'apps/environment' property does not match the required schema: 'command' is a required property

i checked python 3.8.2 documentation Here, but there is no such additional field like environment. so i really confused to where to add this field.

if don’t mind, it really helps me if you share sample file that contains this variable information.

Thanks for replying. you’re great. Thanks again.

like this …

apps:
  testapp:
    command: bin/testapp
    environment:
      PYTHONPATH: $SNAP/usr/lib/python2.7/site-packages:$SNAP/usr/lib/python2.7/dist-packages:$PYTHONPATH

though if you are using python3.x you indeed want to fix the version numbers in the variable to point to your 3.x dirs…

1 Like

thanks brother…it worked and i finally created my first snap application.

Thanks again. :smiley::smiley::smiley::+1::+1:

can you have a tutorial likes , How to create python GUI snap ?? i’m really looking forward to it.

and it helps if you tell me how to set dependency of python library files likes sys,os,numpy etc. in setup.py python script and necessary changes in snapcraft.yaml file.

Thank you for helping me out. Thanks.

1 Like

Publish error::

after running snapcraft register testapp-m11

console output is::

We always want to ensure that users get the software they expect
for a particular name.

If needed, we will rename snaps to ensure that a particular name
reflects the software most widely expected by our community.

For example, most people would expect ‘thunderbird’ to be published by
Mozilla. They would also expect to be able to get other snaps of
Thunderbird as 'thunderbird-$username'.

Would you say that MOST users will expect 'testapp-m11' to come from
you, and be the software you intend to publish there? [y/N]: y
Registering testapp-m11.
You already own the name 'testapp-m11'.

it shows that i already own the name.

but when i try to push my testapp then it will show error like:

push command:
snapcraft push --release=beta testapp_0.1_amd64.snap

console log:

Preparing to push 'testapp_0.1_amd64.snap'.
After pushing, the resulting snap revision will be released to 'beta' when it passes the Snap Store review.
Install the review-tools from the Snap Store for enhanced checks before uploading this snap.
You are not the publisher or allowed to push revisions for this snap. Ensure you are logged in with the proper account and try again.

My account credential is same as Ubuntu-One account.

what should i do to solve this error.?