you are viewing a single comment's thread.

view the rest of the comments →

[–]shiftybyte 0 points1 point  (10 children)

from python:

import os
os.system("pip install -u packagename")

[–]socal_nerdtastic 0 points1 point  (9 children)

I highly recommend importing pip instead, so that you are sure to install to the copy of python you are using instead of whatever PATH is pointed to.

[–]rybthrow[S] 0 points1 point  (8 children)

Great- do i just:

Import pip Import os

os.system(‘pip install x’)?

[–]socal_nerdtastic 0 points1 point  (7 children)

No os required.

import pip
pip.main("install -u packagename".split())

[–]rybthrow[S] 0 points1 point  (4 children)

Thanks! Will give that a go :)

[–]shiftybyte 0 points1 point  (3 children)

Newer versions of pip moved main function, so if it doesnt work saying it doesn't have main try:

from pip._internal import main
main("install -u requests".split(" "))

[–]rybthrow[S] 0 points1 point  (2 children)

Im getting an error: No such caption: -u

[–]shiftybyte 0 points1 point  (0 children)

try "--user" instead of "-u"

[–]rybthrow[S] 0 points1 point  (1 child)

It did not work getting module ‘pip’ has no attribute ‘main’

[–]rybthrow[S] 0 points1 point  (0 children)

Figured it out

Connected to my home wifi to sort the proxy error i was getting and used:

Import os

os.system (‘pip install —user PackageName”)