0

I have a code in my setup.py file:

from setuptools import setup, find_packages


setup(
    name='PBI_telegrambot',
    version='0.0.1',
    author='junscience',
    description='Embedding app for classification',
    packages=find_packages(include =['telegram_bot.py', 'login.py', 'screenshot.py']),
    scripts=['telegram_bot.py'],
    entry_points={
        'console_scripts':[
            'PBI_telegrambot=telegram_bot:main'
        ]
    }
)

The tree of my project looks like:




├── build
│   ├── bdist.linux-x86_64
│   └── scripts-3.8
│       └── telegram_bot.py
├── dist
│   └── PBI_telegrambot-0.0.1-py3.8.egg
├── env.txt
├── login.py
├── PBI_telegrambot.egg-info
│   ├── dependency_links.txt
│   ├── entry_points.txt
│   ├── PKG-INFO
│   ├── requires.txt
│   ├── SOURCES.txt
│   └── top_level.txt
├── pycache
│   ├── login.cpython-311.pyc
│   └── screenshot.cpython-311.pyc
├── requirements.txt
├── screenshot.py
├── setup.py
└── telegram_bot.py

Firstly, I install requirements, by: pip install -r requirements.txt I try to install code in Ubuntu: sudo python3 setup.py install and run it: PBI_telegrambot but receive an error:



/usr/lib/python3/dist-packages/requests/init.py:89: RequestsDependencyWarning: urllib3 (2.2.2) or chardet (5.2.0) doesn't match a supported version!

  warnings.warn("urllib3 ({}) or chardet ({}) doesn't match a supported "

Traceback (most recent call last):

  File "/usr/local/bin/PBI_telegrambot", line 11, in <module>

    load_entry_point('PBI-telegrambot==0.0.1', 'console_scripts', 'PBI_telegrambot')()

  File "/usr/lib/python3/dist-packages/pkg_resources/init.py", line 490, in load_entry_point

    return get_distribution(dist).load_entry_point(group, name)

  File "/usr/lib/python3/dist-packages/pkg_resources/init.py", line 2854, in load_entry_point

    return ep.load()

  File "/usr/lib/python3/dist-packages/pkg_resources/init.py", line 2445, in load

    return self.resolve()

  File "/usr/lib/python3/dist-packages/pkg_resources/init.py", line 2451, in resolve

    module = import(self.module_name, fromlist=['name'], level=0)

  File "/usr/local/bin/telegram_bot.py", line 4, in <module>

    import('pkg_resources').run_script('PBI-telegrambot==0.0.1', 'telegram_bot.py')

  File "/usr/lib/python3/dist-packages/pkg_resources/init.py", line 667, in run_script

    self.require(requires)[0].run_script(script_name, ns)

  File "/usr/lib/python3/dist-packages/pkg_resources/init.py", line 1452, in run_script

    raise ResolutionError(

pkg_resources.ResolutionError: Script 'scripts/telegram_bot.py' not found in metadata at '/home/user/.local/lib/python3.8/site-packages/PBI_telegrambot-0.0.1.dist-info'

Would be grateful for your help!

I try to make a project with pip: pip install ., but have the same problem

7
  • 3
    What are you hoping to accomplish? Running pip install from inside setup.py is just crazy. Commented Jul 16, 2024 at 13:51
  • 1
    Thank you for answers! I tried to make code more powerful by launching it with 1 command, but I will use you advice and clean this part of code:) Commented Jul 16, 2024 at 14:11
  • What about running with PBI_telegrambot, it has been written in last option: entry points of function "setup. Commented Jul 16, 2024 at 14:16
  • 1
    It's amazing how many misconceptions you have. setup.py doesn't start anything. You defined PBI_telegrambot as an entry point; for it setuptools creates a script that tries to import telegram_bot and call its main() — and failed because your telegram_bot is not an importable module. You cannot import from a script. A script is there to run directly, not to be used in entry points. Commented Jul 16, 2024 at 15:15
  • 1
    Thank you for the full explanation! Maybe it's really important to learn about setuptools more to increase my intuition about entry points and import of this library. Commented Jul 17, 2024 at 6:04

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.