upgrading python module within code

2024/9/16 23:10:27

My question relates to this question: Installing python module within code, but involves upgrading the module.

I've tried

packages=['apscheduler','beautifulsoup4','gdata']def upgrade(packages):for package in packages:pip.main(['install --upgrade', package])

and

def upgrade(packages):for package in packages:pip.main(['install', package + ' --upgrade'])
Answer

Try pip.main(['install', '--upgrade', package]).

"--upgrade" is a separate command-line argument, so you need to pass it separately to main.

https://en.xdnf.cn/q/72610.html

Related Q&A

Django - 403 Forbidden CSRF verification failed

I have a contact form in Django for my website and when I was testing it locally it was working fine but now when I try to submit my contact form "live" it always comes up with 403 Forbidden …

Python model object validation

Im writing an interface to be used by two applications. This interface should use some DoSomethingRequest and DoSomethingResponse classes to do the communication.Is there any library that does some mod…

Cassandra 1.2 inserting/updating a blob column type using Python and the cql library

IntroI have a blob column on a Cassandra 1.2 column family, the table is defined as follows:CREATE TABLE objects (id text,obj blob,PRIMARY KEY (id) );The problem:The problem is that when I…

Using python with subprocess Popen

I am struggling to use subprocesses with python. Here is my task:Start an api via the command line (this should be no different than running any argument on the command line) Verify my API has come …

ipdb, multiple threads and autoreloading programs causing ProgrammingError

I am using ipdb debugger to debug multithreaded web applications locally (Django, Plone). Often ipdb seems to get confused because of the autoreload which happens when I am on the debug prompt. The res…

How to turn off logging buffer to get logs in real time with python command line tool?

I have a command line tool which produces plenty of logs. I want these logs to be sent to stdout as soon as theyre made. Right now, the program finishes everything (which can take several minutes), and…

How to tell if process is responding in Python on Windows

I am writing a python script to keep a buggy program open and I need to figure out if the program is not respoding and close it on windows. I cant quite figure out how to do this.

How to load and use a pretained PyTorch InceptionV3 model to classify an image

I have the same problem as How can I load and use a PyTorch (.pth.tar) model which does not have an accepted answer or one I can figure out how to follow the advice given.Im new to PyTorch. I am trying…

Append list to pandas DataFrame as new row with index

Despite of the numerous stack overflow questions on appending data to a dataframe I could not really find an answer to the following. I am looking for a straight forward solution to append a list as la…

IPC between Python and C#

I want to pass data between a Python and a C# application in Windows (I want the channel to be bi-directional) In fact I wanna pass a struct containing data about a network packet that Ive captured wit…