Hi Pedro, I think I've seen some code that does this before, but I can't find it now. It's generally regarded as a crazy hack, and I wouldn't recommend anyone use it except as a joke/demo. Some of the reasons:
1. Downloading and running code from the internet if you mistype an import statement is a pretty major security hole. 2. Import names aren't always the same as install names (e.g. 'pip install pyzmq' -> 'import zmq'). There are ways around it (https://pypicontents.readthedocs.io/en/latest/ ), but it's not trivial. 3. Correctly installing a module and then loading it in your running process isn't always easy: what if it requires an updated version of another package you've already imported? 4. Having a separate step where you explicitly install things makes it easier to customise the process of finding and installing them, e.g. if you want to run software on a machine which doesn't have an internet connection. It might be convenient for some use cases to have 'magic' imports that install the package if necessary, but overall it would be unreliable and confusing. There are various efforts to simplify managing dependencies of a project - see e.g. https://pypi.org/project/pipenv/ or https://pypi.org/project/poetry/ . Best wishes, Thomas On Tue, Mar 12, 2019, at 12:30 PM, pedroguilhermealv...@gmail.com wrote: > Hi, how are you? > > > I'm trying to create a thing, an idea, a thought. This is about the Pip > package management system used to install and manage software packages > written in the Python programming language. > > So I wanted it to be automatic. Instead of always typing ... > > For example > > pip install example.py > Solution > What if Python itself had this automatic feature internally? > > For example > > impot example1 # runs pip install example.py > Case > > A. If you do not have the module, the module will be inserted. > B. If you have the module, check the installed version. > > Summary > It would be a 'package.json, similar to the Nodejs' within Python. > > Note > > I expect an answer > Thank you for your attention and respect, > I'm starting with Python and I have this idea > If the community helps and if I can help, it would be an honor for this > idea, implementation ^^ > Regards, > Pedro Guilherme > > > About this > > Note 1 > > I tried to get an answer on Github and asked to check it out here. If > the discourse is good, we can include it in the Github repository for > this new feature or implementation. I'm going to thank Mariatta for > this tip. > > Written message, reply > " Thanks for your interest in improving Python. However the devguide is > not the right place to discuss the proposed idea. From the sound of it, > perhaps distutils-sig? " Here I am... > > > Note 2 > > The reference at the end is a link about it. It was closed in the > python devguide and peps repositories in the issues area. I want more > clarification about my thinking. I like to create and think. My little > visual projects were thanks to what I found, vi, li, I researched in > Stackoverflow, Github, Codepen.io. > > > Note 3 > I'm trying to translate the Arduino into Portuguese. > Library Brasilino ... ^^ > And I'm adapting or suggesting the next words ... to be a bit like > English .... It's that Portuguese has a graphic accent and English does > not. For example, consider the word 'Sr não = If no' associated with > this 'else'. So I'm reading dictionaries to find a word next to English > ... without a graphic accent on what is considered in English. > > Resume > Here https://github.com/OtacilioN/Brasilino and see in content 'issues' ^^ > > Regards, > Pedro Guilherme > > > > > > Reference > https://github.com/python/devguide/issues/469 > -- > Distutils-SIG mailing list -- distutils-sig@python.org > To unsubscribe send an email to distutils-sig-le...@python.org > https://mail.python.org/mailman3/lists/distutils-sig.python.org/ > Message archived at > https://mail.python.org/archives/list/distutils-sig@python.org/message/TVCV24AS6VECWTWHL524QJULLHJVWXJA/ > -- Distutils-SIG mailing list -- distutils-sig@python.org To unsubscribe send an email to distutils-sig-le...@python.org https://mail.python.org/mailman3/lists/distutils-sig.python.org/ Message archived at https://mail.python.org/archives/list/distutils-sig@python.org/message/YD5TOULRFJYKEOYQVLCGJREUMUJKL26G/