VS Python environment to install third-party packages pip

2019.5.27

Systems & Software Environment: Windows 10 Pro 1809, Visual Studio 2019 16.1.0, Python 3.7.2


There are many online posts that pip change domestic source approach, now to test for VS installed Python environment to no avail.

Open Visual Studio, a new Python application project.

Pictures .png

Figure I


I always open on the right side shows the Python environment, this interface can also be opened in the following ways:

Expand the "Solution Explorer" in the Python environment, this project shows the actual use of the Python environment, in this environment right 3.7, click on the red box, it will interface to the map.

Pictures .png

Figure II


FIG select a block in the "package (the PyPI)", later on, there will be installed the following package. Red box box below, you can enter the name of the package you want to install.

Pictures .png

Figure III


Such as input tensorflow, in fact, command execution is pip install tensorflow. If the temporary use of domestic sources, you can add parameters, such as --index https://pypi.mirrors.ustc.edu.cn/simple/ tensorflow, the actual implementation is pip install --index https: // pypi. mirrors.ustc.edu.cn/simple/ tensorflow



Obviously this long and hard, so try to modify a permanent way. Enter % HOMEPATH% directory:

Pictures .png

Figure IV


AK is my computer's user name. New pip directory, create a text document named pip.ini, stick into the following:

[global]

timeout = 6000

index-url = https://pypi.tuna.tsinghua.edu.cn/simple

trusted-host = pypi.tuna.tsinghua.edu.cn


在VS中安装setuptools包(实际上是升级了),在Visual Studio左下方“输出”窗口出现如下信息(图一)

----- 正在安装“setuptools” -----
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting setuptools
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/ec/51/f45cea425fd5cb0b0380f5b0f048ebc1da5b417e48d304838c02d6288a1e/setuptools-41.0.1-py2.py3-none-any.whl (575kB)
Installing collected packages: setuptools
  Found existing installation: setuptools 40.8.0
    Uninstalling setuptools-40.8.0:
      Successfully uninstalled setuptools-40.8.0
Successfully installed setuptools-41.0.1
----- 已成功安装“setuptools” -----


说明成功修改为国内源。



参考链接:

[1]vs2017 python环境安装第三方包 - HPUGIS的博客 - CSDN博客

https://blog.csdn.net/weixin_40184249/article/details/80720015

(Powershell还是算了吧)

[2] PIP replace domestic installation source - Perry.Yuan - CSDN blog
https://blog.csdn.net/yuzaipiaofei/article/details/8089110


P.S.

Pictures .png

The figure is a position I installed VS, so:

E: \ Program Files (x86) \ Microsoft Visual Studio \ Shared \ Python37_64 \ Lib \ site-packages to install third-party libraries are placed here, such as NumPy.

E: \ Program Files (x86) \ Microsoft Visual Studio \ Shared \ Python37_64 \ Scripts pip under this directory.


Some pip domestic mirror

  Ali cloud http://mirrors.aliyun.com/pypi/simple/ 
  China University of Science and Technology https://pypi.mirrors.ustc.edu.cn/simple/ 
  watercress (douban) http://pypi.douban.com/simple / 
  Tsinghua https://pypi.tuna.tsinghua.edu.cn/simple/ 
  University of Science and technology of China http://pypi.mirrors.ustc.edu.cn/simple/


Guess you like

Origin blog.51cto.com/12078224/2401112
Recommended