Python Forum
Installing Modules / packages
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Installing Modules / packages
#1
Is there any script to make python install a pip module?

Ex :
try:
    import Module
except:
    install Module
Reply
#2
I have found this code earlier to do so (not my work though, but it worked for me)

import subprocess
import sys

def install(package):
    subprocess.check_call(
        [sys.executable, "-m", "pip", "install", package])

install('pandas')
So in your case your exception should include the code within the code in my install function. In this case 'pandas' is an example ofcourse.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Installing python packages in a virtual environment Led_Zeppelin 1 711 Aug-15-2023, 08:18 PM
Last Post: deanhystad
  installing prospector and updating anaconda packages amir 2 957 Dec-24-2022, 06:13 AM
Last Post: amir
  Installing Modules PythonBorg 10 1,959 Sep-03-2022, 09:58 AM
Last Post: PythonBorg
Question Trouble installing modules/libraries and getting Notepad++ to show cyrillic letters Dragiev 6 2,179 Jul-24-2022, 12:55 PM
Last Post: Dragiev
  Conversion of Oracle PL/SQL(packages, functions, procedures) to python modules. DivyaKumar 2 6,412 Jul-09-2020, 04:46 PM
Last Post: srikanth7482
  Getting error while installing packages using pip Shreya 2 3,957 Apr-22-2020, 08:03 AM
Last Post: Shreya
  installing third-party modules shabux 5 3,365 Apr-13-2020, 12:41 AM
Last Post: Larz60+
  Installing Packages Cydney 6 3,199 Mar-31-2020, 01:13 PM
Last Post: Cydney
  Installing PIP packages issue Renym 2 3,007 Dec-09-2019, 04:44 PM
Last Post: Axel_Erfurt
  Python 3.8 or 3.? Trouble installing packages dn237 5 6,720 Oct-25-2019, 07:21 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020