windows下多Python环境指定pip安装模块到对应Python环境下

老猿在windows下装了2套Python,一套是直接安装的Python3.7,一套是通过安装Anaconda3时安装的,版本也是3.7,结果今天安装一个模块后,进入Python37后找不到该模块,才想起是安装了两个Python导致。那么在windows下pip安装模块时安装到哪个Python环境是怎么决定的呢?是通过path环境变量来指定的,在path环境变量中,哪个Python的路径在前,模块就安装到哪个Python环境下。

这是老猿安装时的path环境变量:

d:Anaconda3;d:Anaconda3Librarymingw-w64bin;d:Anaconda3Libraryusrbin;d:Anaconda3Librarybin;d:Anaconda3Scripts;C:Program FilesPython37Scripts;C:Program FilesPython37;%JAVA_HOME%bin;C:TEMP

所以安装时就安装到了Anaconda3对应的环境下了,如果要调整为安装到Python37环境下,将path环境变量调整为:

C:Program FilesPython37Scripts;C:Program FilesPython37;d:Anaconda3;d:Anaconda3Librarymingw-w64bin;d:Anaconda3Libraryusrbin;d:Anaconda3Librarybin;d:Anaconda3Scripts;%JAVA_HOME%bin;C:TEMP

即可。

老猿Python,跟老猿学Python!

原文地址:https://www.cnblogs.com/LaoYuanPython/p/12634941.html