We have to install package in python playground | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

We have to install package in python playground

Is it required to install packages or just we have to import package to run python code and if we have to install packages then how? Please help me🙏

27th Jul 2021, 1:40 PM
Arun Jamson
Arun Jamson - avatar
3 Answers
+ 3
You can import the python builtin packages. And if you want to import other 3rd party packages you need to install them first . Type these lines at the top of script . packages_name=["package1", "package2"] import sys import subprocess subprocess.check_call(["sys.executable", "-m", "pip", "-q", "--disable-pip-version-check", "install", *packages_name]) These packages will be installed only when you run the script and will be removed later on after you exit .
27th Jul 2021, 1:49 PM
Abhay
Abhay - avatar
+ 1
Try importing, if it don't work you only have one other option
27th Jul 2021, 1:57 PM
Slick
Slick - avatar
0
Ok for example phoneNumber package I have to install or simply import
27th Jul 2021, 1:54 PM
Arun Jamson
Arun Jamson - avatar