Python Forum
Cannot package application using pip; ModuleNotFoundError
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Cannot package application using pip; ModuleNotFoundError
#1
I have been trying for months to work out how to correctly package my python application for use with pip.

I can upload the application to pypi without problems:

> python3 setup.py sdist bdist_wheel
> twine check dist/*
> twine upload dist/*

I can install from pip without obvious problems:

> sudo apt install python3-pip
> sudo pip3 install tartube

But the application will not run. There are two issues: firstly, the main script (in /usr/local/bin) can't see any other python modules, even though they have been correctly installed to /usr/local/lib/python3.6/dist-packages.

Secondly, a folder full of icons doesn't seem to be installed at all.

I've read about a billion "how to package your python apps" tutorials, none of which provide any clues. Presumably the setup.py file is at fault; can anyone see any obvious problems with it?

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# Import modules
import os
import setuptools
import sys

# For the Debian distribution, use an environment variable. When specified,
#   the 'tartube_debian' file is the executable, rather than the 'tartube'
#   file
# When the 'tartube_debian' file is the executable, youtube-dl updates are
#   disabled, and Tartube's config file is stored at $XDG_CONFIG_HOME
# The package maintainer should use
#   TARTUBE_NO_UPDATES=1 python3 setup.py build
env_var_name = 'TARTUBE_NO_UPDATES'
env_var_value = os.environ.get( env_var_name, None )
script_exec = os.path.join('tartube', 'tartube')

if env_var_value is not None:

    if env_var_value == '1':
        script_exec = os.path.join('tartube', 'tartube_debian')
        sys.stderr.write('youtube-dl updates are disabled in this version')

    else:
        sys.stderr.write(
            "Unrecognised '%s=%s' environment variable!\n" % (
                env_var_name,
                env_var_value,
            ),
        )


# Setup
setuptools.setup(
    name='tartube',
    version='1.3.077',
    description='GUI front-end for youtube-dl',
    long_description="""Tartube is a GUI front-end for youtube-dl, partly based
        on youtube-dl-gui and written in Python 3 / Gtk 3""",
    long_description_content_type='text/markdown',
    url='https://tartube.sourceforge.io',
    author='A S Lewis',
    author_email='[email protected]',
    classifiers=[
        'Development Status :: 3 - Alpha',
        'Intended Audience :: End Users/Desktop',
        'Topic :: Multimedia :: Video',
        'License :: OSI Approved' \
        + ' :: GNU General Public License v3 or later (GPLv3+)',
        'Programming Language :: Python :: 3',
        'Programming Language :: Python :: 3.4',
        'Programming Language :: Python :: 3.5',
        'Programming Language :: Python :: 3.6',
        'Programming Language :: Python :: 3.7',
    ],
    keywords='tartube video download youtube',
    packages=setuptools.find_packages(
        exclude=('docs', 'icons', 'nsis', 'tests'),
    ),
    include_package_data=True,
    python_requires='>=3.0, <4',
    install_requires=['requests', 'xdg'],
    scripts=[script_exec],
    project_urls={
        'Bug Reports': 'https://github.com/axcore/tartube/issues',
        'Source': 'https://github.com/axcore/tartube',
    },
)

Can't find the edit post button. Here is the actual error message generated:

Output:
Traceback (most recent call last): File "/usr/local/bin/tartube", line 33, in <module> import mainapp ModuleNotFoundError: No module named 'mainapp'
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  "ModuleNotFoundError: No module named 'PyQt5.QtWidgets'; 'PyQt5' is not a package" chipx 3 7,240 Dec-09-2021, 07:05 AM
Last Post: chipx
Question Setuptools CLI program ModuleNotFoundError after splitting up module into package Postbote 1 2,279 Nov-25-2021, 06:35 PM
Last Post: Postbote
  How to send data from a python application to an external application aditya_rajiv 1 2,131 Jul-26-2021, 06:00 AM
Last Post: ndc85430
  ModuleNotFoundError when application is not installed via setup.py bytebutcher 3 2,113 Jan-08-2021, 10:28 AM
Last Post: Gribouillis
  ModuleNotFoundError: No module named 'scipy.optimize'; 'scipy' is not a package AaronKR 1 10,090 Jul-09-2020, 02:36 AM
Last Post: bowlofred
  ModuleNotFoundError: No module named 'http.client'; 'http' is not a package abhishek81py 1 15,243 Jun-25-2020, 08:58 AM
Last Post: buran
  Generate RPM package from a Python + Kivy application for an "offline" installation pruvosim 2 2,166 Jun-04-2020, 12:16 PM
Last Post: pruvosim
  ModuleNotFoundError: No module named '__main__.vtt'; '__main__' is not a package MM2018 26 16,601 Oct-12-2018, 05:40 AM
Last Post: MM2018

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020