Python third-party library installation location

1. Install the third-party library to a specific location

If you select a certain version of python in vscode, the requirement to install pylint, pycodestyle pops up (as shown below), the installation location is C:\\Users\\xinglei\\AppData\\Roaming\\Python\\Python36\\ site-packages and (doesn't exist) will also become existing.

It is best not to install any third-party libraries through the prompt popped up by vscode. The third-party libraries installed with the package name of pip install will be under D:\\Python36\\lib\\site-packages, which is convenient for future reference and management.

2. When installing a third-party library for a certain version of python, first check the pip to be used and then install it, as shown in the figure below.

To install third-party libraries for python36, use the pip3.6 install package name, and install third-party libraries for python38 to use the pip3.8 install package name.

3. View the information of the installed libraries for a specific version of python.

Use pip3.7 list to view the libraries installed by python37.

Use pip3.7 show requests to view the detailed information of the requests library installed by python37. (Here my python37 is a component installed by visual studio, so the installation location of the library is not the location I hope)

4. Open both pycodestyle and pylint format checking tools in vscode.

First install pylint and pycodestyle, the installation method is shown above, and the setting method is as follows.

Taking the simultaneous enabling of pylint and pycodestyle in python38 as an example, you can directly search for python.linting.pylintEnabled and python.linting.pycodestyleEnabled in the search bar.

5. Under the premise of using pylint and pycodestyle, solve the error message when the number of characters in a line is too long.

Add two configuration files under the python project, the contents of the two files are the following configuration file contents.

Configuration file content:

[pycodestyle]
count = True
ignore = E226,E302,E41
max-line-length = 500
statistics = True

6. Change the pip installation source to get the best download speed of third-party libraries.

Set pip installation source:
    choose one of the following installation sources.
    (1)     Alibaba Cloud http://mirrors.aliyun.com/pypi/simple/
    (2) Douban http://pypi.douban.com/simple/
(3) Tsinghua University https://pypi.tuna.tsinghua. edu.cn/simple/
    (4) University of
    Science and Technology of China http://pypi.mirrors.ustc.edu.cn/simple/ (5) Huazhong University of Science and Technology http://pypi.hustunique.com/

    Temporarily use the domestic mirror source (taking the pandas package installation via pip as an example).
        pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pandas

    Permanently replace the installation source.
        Create a new file C:\Users\xl\pip\pip.ini (xl in the path is the user name, and the actual user name shall prevail), and add the following content to the file (to replace it with https://pypi.tuna.tsinghua .edu.cn/simple installation source as an example), save it to take effect and it is valid for all versions of python that have been installed.

The content of the pip.ini file:
[global]
timeout = 6000
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
trusted-host = pypi.tuna.tsinghua.edu.cn

Guess you like

Origin blog.csdn.net/qq_34473570/article/details/108372059