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
  Conversion of Oracle PL/SQL(packages, functions, procedures) to python modules. DivyaKumar 3 8,459 Oct-01-2024, 03:32 PM
Last Post: Alex_Kirpichny
  Installing python packages in a virtual environment Led_Zeppelin 1 1,742 Aug-15-2023, 08:18 PM
Last Post: deanhystad
  installing prospector and updating anaconda packages amir 2 1,903 Dec-24-2022, 06:13 AM
Last Post: amir
  Installing Modules PythonBorg 10 4,065 Sep-03-2022, 09:58 AM
Last Post: PythonBorg
Question Trouble installing modules/libraries and getting Notepad++ to show cyrillic letters Dragiev 6 4,108 Jul-24-2022, 12:55 PM
Last Post: Dragiev
  Getting error while installing packages using pip Shreya 2 6,252 Apr-22-2020, 08:03 AM
Last Post: Shreya
  installing third-party modules shabux 5 5,078 Apr-13-2020, 12:41 AM
Last Post: Larz60+
  Installing Packages Cydney 6 4,934 Mar-31-2020, 01:13 PM
Last Post: Cydney
  Installing PIP packages issue Renym 2 3,991 Dec-09-2019, 04:44 PM
Last Post: Axel_Erfurt
  Python 3.8 or 3.? Trouble installing packages dn237 5 8,516 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