0

How can I install Python modules?

I have been trying to work on some projects and yet I can't because it would be displaying on the console that that module can't be found

27th May 2023, 9:23 AM
Ever Gospel Ndep
Ever Gospel Ndep - avatar
12 Antworten
+ 2
Ever Gospel Ndep You can't compare sololearn's compiler to an the ones on your machine because sololearn's compiler is basically for learning purposes only and I don't think it can install external modules
28th May 2023, 7:31 PM
Maduike Uchenna
Maduike Uchenna - avatar
+ 6
Snehil , using the provided installation procedure should not be part of a regular program (outside of sololearn), since it will run and try to install with each execution of the code file. in sololearn playground it has to be as described. > we may run it in a *try: ... except:..* block, so that it only runs if module can not be imported. > an other point is that the installation runs silently, so no feedback about installation state, messages or warnings are shown.
27th May 2023, 4:24 PM
Lothar
Lothar - avatar
+ 4
__import__('os').system('pip install -qq package1 package2') use this statement at the first line of your program
27th May 2023, 9:27 AM
Just Some Random Guy
Just Some Random Guy - avatar
+ 4
in the terminal pip install module_name
27th May 2023, 10:33 AM
Hazem Hadj Ahmed
Hazem Hadj Ahmed - avatar
+ 2
Lothar I appreciate you for pointing that my answer is incomplete. But providing a complete answer would have been more helpful to the user. I think you left that part on me so I'll share the way what actually to do on sololearn's Linux container and on real machine. In the Sololearn environment, as I mentioned, the IDE runs in a Linux Container, and any installed modules are specific to that container and do not persist beyond the program execution. To work with external packages in Sololearn, you can include the necessary installation commands within your Python code using the os module. On a real machine, you can directly execute the pip install command in the terminal or command prompt without the need for any additional steps. -qq used in the command is quite mode flag it hides all the stats of installation. ========= I can't type more details as there's character limit. do research every point and ask further doubts
27th May 2023, 5:14 PM
Just Some Random Guy
Just Some Random Guy - avatar
+ 1
Oh really
27th May 2023, 9:29 AM
Ever Gospel Ndep
Ever Gospel Ndep - avatar
+ 1
Thanks Snehil
27th May 2023, 9:29 AM
Ever Gospel Ndep
Ever Gospel Ndep - avatar
+ 1
Hazem Hadj Ahmed where can I get the terminal in sololearn?
27th May 2023, 4:47 PM
Ever Gospel Ndep
Ever Gospel Ndep - avatar
+ 1
Lothar I don't understand
27th May 2023, 4:48 PM
Ever Gospel Ndep
Ever Gospel Ndep - avatar
+ 1
If you have a windows computer, then go to command prompt, and type: pip install library-name Hope this helps.
27th May 2023, 5:09 PM
Danish Zubair
Danish Zubair - avatar
0
Danish Zubair there are modules installed on my machine but can't use them here on sololearn
28th May 2023, 1:07 PM
Ever Gospel Ndep
Ever Gospel Ndep - avatar
0
Ever Gospel Ndep Yeah, because Sololearn's compiler is not a professional compiler, such as Pycharm or VS code, try on these compilers, and it should work. Note that online compiler doesn't support any external libraries, they only support the library which are built in in the compiler.
28th May 2023, 2:05 PM
Danish Zubair
Danish Zubair - avatar