Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
953 views
in Technique[技术] by (71.8m points)

mobile - Running Python on USB

I'm trying to set up a USB I have with a full Python suite. I want to be able to download modules and other useful libraries to the thumb drive, create scripts and modules of my own and even export programs, all from the USB. I want to do this so that I can work on projects from any computer without having to download any software to that particular PC.

I think I have to create a virtual environment on the USb first, but beyond that I'm not sure if its possible or feasible to accomplish this.

Any advice on how to proceed, if I can?

question from:https://stackoverflow.com/questions/65890829/running-python-on-usb

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I assume you already installed python on windows and added it in your PATH. for making a python virtual environment do these steps:

Step 1: Change Directory

open cmd and write your UBS assigned letter + : to change the directory. assuming your USB is mounted as D volume.

C:UsersName>D:

D:>

Step 2: Creating Virtual Environment

D:>python -m venv otg

you can substitute otg with any name you want.

Step 3: Activating Virtual Environment

D:>otgScriptsactivate.bat

now you are in the created virtual environment. the CMD prompt must be sth like this

(otg) D:>

install whatever you want. to confirm that everything is Ok, the where python command in cmd must return sth like this:

D:otgScriptspython.exe

Step 4: Exiting From Environment

after you finished your work you can exit the virtual environment by issuing this command

(otg) D:>deactivate

Now you can unplug your USB and attach it to any other system. to access the python environment you just need to repeat steps 1, 3 and 4. for more information about virtual environments Python Docs is a good source.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...