Create a portable Python development environment and install Python into the U disk

Create a portable Python development environment and install Python into the U disk

1. Background introduction

Many times you need a portable Python development environment, which is convenient to use on a PC without a network or a Python development environment. Install the Python development environment on a USB flash drive and carry it with you. You don t have to carry a heavy laptop and run around. Use your familiar development environment.

2. Installation steps

1. download the Python release version and go to the official website to download it.

Python official website

The latest version of python is Python 3.8.2, but many third libraries have not been updated. It is recommended to use the Python 3.7.7 installation package.

Select Windows x86-64 executable installer

Pyhon provides multiple types of installation packages, here we choose Windows x86-64 executable installer

Official website download address Python 3.77

If the download is slow, you can use the network disk to download:

Netdisk download

Click the installation package to install

Pay attention to click and check

Waiting for the end of the installation, the Python development environment has been set up.

Check the system environment variables, the Python installation directory has been added to the system environment variables, and now you can use Python to develop programs.

Here comes the point

Since you want to build a portable development environment, you have to put Python anywhere you want to use it. Next we move the Python installation directory to the desktop to see if it can be used.

Find the Python installation directory, copy the Python installation directory to the desktop directory, and add the new installation path modification to the system environment variables. Now you can uninstall the previously installed Python.

Can it be used like this? Not yet.

Let's try to install a third package with pip.

error.

Where is the problem? There is a problem with the exe file in the Scripts directory under the Python installation directory. The exe has written the python environment variable to death. We need to modify the exe file in the Scripts directory and change the environment variable to a relative path.

Sacrifice the artifact WinHex

winhex

Use WinHex to modify the exe file. The revised content is at the end.

before fixing
After modification

All exe files in the Scripts directory can be modified in this way.

Now you can use all the functions of Python.