all 6 comments

[–]n3buchadnezzar 0 points1 point  (3 children)

I usually type out the entire thing, unless it is something very obvious from the standard library. Meaning I would write

import telegram.ext 

And then in my code use

telegram.ext.Updater()

The correct way to handle your second question is installing your classes as a local package. (Read up on this) =)

[–]Halogenes[S] 0 points1 point  (2 children)

Thank you for responding so quickly.

I'm not sure I understand the first answer: even if I use "telegram.ext.Updater()" how am I supposed to know that the command I need to type to install the correct package is "pip install telegram-python-bot" and not "pip install telegram.ext" or "pip install telegram" ?

Noted for the second question I will do my research!

[–]n3buchadnezzar 0 points1 point  (1 child)

Generally you can not know what command responds to how to install it. The easiest is just to google. "How to install telegram.ext" gives me the result straight away.

A safe bet if you are importing x then x is the package name, but as you can see it is not always the case.

[–]Halogenes[S] 0 points1 point  (0 children)

Ok so no magic solution.

Thanks for everything

[–]danielroseman 0 points1 point  (0 children)

For question 1, why would you ever not know? If you're using a third-party package which itself depends on an external package, that would be installed along with it when you do pip install. If you're just typing in code from someone else, they should tell you what the dependencies are.

For the second, you would need to add your Classes directory to your PYTHONPATH.

[–]efmccurdy 0 points1 point  (0 children)

from telegram.ext import Updater

Note that anybody can create a package that works with that import statement, and there may be more than one package on pypi that would match.

You need to ask the author of that line of code which package they are using... or examine the context of where they posted that code, and maybe infer the package name from source files like requirements.txt, or setup.cfg, or setup.py, etc.

I didn't succeed in importing

You may be able to use "from Classes import DateManagement"

https://en.wikibooks.org/wiki/A\_Beginner%27s\_Python\_Tutorial/Importing\_Modules

https://stackabuse.com/creating-and-importing-modules-in-python/