Unable to find python3

I have a snapcraft that uses python3 as a plug.

When I do a clean on a single part and then attempt a build I’m getting an error:

snapcraft            
Skipping pull tomcat-with-ssl (already ran)
'orion-monitor-webapp' has prerequisites that need to be staged: tomcat-with-ssl
Preparing to build tomcat-with-ssl 
Building tomcat-with-ssl 
Unable to find python3, searched: /home/bsutton/git/orionmonitor/snap-projects/installer/stage:/home/bsutton/git/orionmonitor/snap-projects/installer/parts/tomcat-with-ssl/install

However as you can see python3 is installed on the host:

sudo apt install python3
[sudo] password for bsutton: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
python3 is already the newest version (3.5.1-3).

The error only occurs when I clean a single part. If I do a full clean the project builds fine.

name: orion-monitor # you probably want to 'snapcraft register <name>'
version: '0.1' # just for humans, typically '1.2+git' or '1.3.2'
summary: monitoring of orion vms.
description: | 
  OrionMonitor is a webapp designed to monitor Orion Vms and stop/start them
  when they are not required.

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

apps:  
  tomcat:
    command: tomcat-launch
    daemon: simple
    plugs: [network, network-bind]

  # used to ran the certbot renewal process.
  cron:
    command: cron
    daemon: simple
    plugs: [network, network-bind]

  # You must run getcert after the install to create the certificate.
  getcert:
    command: getcert
    plugs: [network, network-bind]

parts: 
  # build the web app
  orion-monitor-webapp:
    plugin: maven
    source: git@bitbucket.org:sbsutton/orionmonitor.git
    maven-options:
      [-DskipTests=true]
    organize:
      war/orionmonitor-1.0-SNAPSHOT.war : webapps/orionmonitor.war
    after: [tomcat-with-ssl]

  tomcat-with-ssl:
    plugin: python
    source: https://github.com/bsutton/tomcat-with-ssl-snap
    source-type: git


1 Like

Any thoughts on this one as it looks like a bug.

It’d help if you shared what version of snapcraft you’re using, and an easy set of steps to reproduce the issue

snapcraft version 2.39

here is a minimal yaml

name: test
version: '0.1' # just for humans, typically '1.2+git' or '1.3.2'
summary: test python bug
description: | 
  test

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

apps:
  tomcat:
    command: certbot
    plugs: [network, network-bind]

parts: 
  certbot:
    plugin: python
    stage-packages:
      - certbot
      - libc6

  tomcat-with-ssl:
    plugin: python
    source: https://github.com/bsutton/tomcat-with-ssl-snap
    source-type: git

bsutton@slayer-3:~/git/orionmonitor/snap-projects/test$ 

run snapcraft

then snapcraft clean certbot

errors ensue.

I may second that. I have exactly same problem and didn’t find a way to solve it

similiar error here using snapcraft, version 2.42.1+18.4

$ snapcraft
Failed to reuse files from previous build: The 'pull' step of 'fbuddy' is out of date:
The 'stage-packages' part property appears to have changed.
To continue, clean that part's 'pull' step, run `snapcraft clean fbuddy -s pull`.
$ snapcraft --debug clean fbuddy -s pull
Starting snapcraft 2.42.1+18.4 from /usr/lib/python3/dist-packages/snapcraft/cli.
Setting up part 'fbuddy' with plugin 'python' and properties {'source': '.', 'plugin': 'python', 'python-version': 'python2', 'requirements': 'requirements.txt', 'stage-packages': ['libc6', 'cron', 'python-setuptools', 'python-gobject-2', 'python-notify', 'python-pip', 'python-tk'], 'stage': [], 'prime': []}.
Skipping cleaning priming area for fbuddy (already clean)
Skipping cleaning staging area for fbuddy (already clean)
Skipping cleaning build for fbuddy (already clean)
Cleaning pulled source for fbuddy 
Traceback (most recent call last):
  File "/usr/bin/snapcraft", line 11, in <module>
    load_entry_point('snapcraft==2.42.1+18.4', 'console_scripts', 'snapcraft')()
  File "/usr/lib/python3/dist-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3/dist-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python3/dist-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3/dist-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/snapcraft/cli/lifecycle.py", line 183, in clean
    lifecycle.clean(project_options, parts, step)
  File "/usr/lib/python3/dist-packages/snapcraft/internal/lifecycle/_clean.py", line 195, in clean
    _clean_parts(parts, step, config, staged_state, primed_state)
  File "/usr/lib/python3/dist-packages/snapcraft/internal/lifecycle/_clean.py", line 87, in _clean_parts
    part_name, step, config, staged_state, primed_state)
  File "/usr/lib/python3/dist-packages/snapcraft/internal/lifecycle/_clean.py", line 50, in _clean_part_and_all_dependents
    config.parts.clean_part(part_name, staged_state, primed_state, step)
  File "/usr/lib/python3/dist-packages/snapcraft/internal/project_loader/_parts_config.py", line 153, in clean_part
    part.clean(staged_state, primed_state, step)
  File "/usr/lib/python3/dist-packages/snapcraft/internal/pluginhandler/__init__.py", line 758, in clean
    step, hint)
  File "/usr/lib/python3/dist-packages/snapcraft/internal/pluginhandler/__init__.py", line 799, in _clean_steps
    self.clean_pull(hint)
  File "/usr/lib/python3/dist-packages/snapcraft/internal/pluginhandler/__init__.py", line 403, in clean_pull
    self.plugin.clean_pull()
  File "/usr/lib/python3/dist-packages/snapcraft/plugins/python.py", line 218, in clean_pull
    self._pip.clean_packages()
  File "/usr/lib/python3/dist-packages/snapcraft/plugins/python.py", line 187, in _pip
    stage_dir=self.project.stage_dir)
  File "/usr/lib/python3/dist-packages/snapcraft/plugins/_python/_pip.py", line 133, in __init__
    install_dir=self._install_dir)
  File "/usr/lib/python3/dist-packages/snapcraft/plugins/_python/_python_finder.py", line 51, in get_python_command
    python_command_name, [stage_dir, install_dir])
snapcraft.plugins._python.errors.MissingPythonCommandError: Unable to find python2, searched: /home/rolonso/Development/FacebookBuddy/FacebookTimeline/stage:/home/rolonso/Development/FacebookBuddy/FacebookTimeline/parts/fbuddy/install

stage and parts directories look like:
image

Is this the intended behaviour or is it a bug?

Encountered this bug on snapcraft 2.42.1

Getting this problem with

$ snapcraft --version
snapcraft, version 2.42.1+18.4