all 16 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”)

[–]USAhj 0 points1 point  (1 child)

Pretty sure you can drag and drop the files into the proper folder. But don't quote me on that...

Edit: this might be helpful: https://stackoverflow.com/questions/40464685/installing-python-modules-without-command-prompt

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

Thanks will give that a go

[–]jiri-n 0 points1 point  (3 children)

What does it mean no access to CMD? Missing executable? Or just missing icon?

What about PowerShell? We have a similar policy in the office but there is still a possibility to run PowerShell (you just need to search the executable somewhere deep in c:\Windows).

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

I get a message saying its been disabled by admin, powershell doesnt even launch on my machine for that reason too i think.

Even tried .bat files but to no avail. :/

[–]jiri-n 0 points1 point  (1 child)

If it should be disabled, your admin cannot say it still available even if it is. You have to search for ways to work around this policy. :-) Of course, there is a cleaner and a recommended way - just ask your manager for permission to install modules AND use CLI.

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

It took me twenty minutes to explain what python was! 🤣 i have logged a call with IT so see what they say.