当前位置:网站首页>conda环境下pip install 无法安装到指定conda环境中(conda环境的默认pip安装位置)
conda环境下pip install 无法安装到指定conda环境中(conda环境的默认pip安装位置)
2022-06-12 11:32:00 【轩卬】
参考:https://blog.51cto.com/u_15060549/4662570
1. 修改当前环境下的路径设置
查看当前环境包的搜索路径 以及用户环境的目录
(类似于 sys.path()的效果) 查看当前环境的包搜索路径(pip默认安装路径
python -m site

因为 pip install 背后实质上是通过 setup.py 来安装python包的;
而 setup.py 中用到 setuptools,安装过程中会用到sys.path信息,虽然上面sys.path中的信息包含 envs/py38,这个虚拟环境路径;
而且sys.path中的目录排序是有优先级顺序的(envs/py38 路径排在.local后面)
再者,当前用户环境目录也是 .local/, 且会最优先用户环境目录进行安装目录的确认;
修改用户环境目录
注:修改的前提是已经进入虚拟环境,这样修改的是虚拟环境下的配置,而不会影响到全局
修改当前环境下的 site.py 文件: ,路径改为上图3中所示对应路径
sudo vim /opt/conda/envs/<your-env>/lib/<python3.8>/site.py # 是否sudo看情况

默认 USER_SITE、USER_BASE 都为None (用的时候会默认填充当前用户的)
接下来把他们修改为conda环境的目录
2. 直接先删除导致冲突的pip,再在当前环境下安装pip
- 先把原始路径上的、local/文件夹里的pip卸载了(删了)
python -m site
删除USER_SITE路径下的pip
- 然后再重装自己虚拟环境里的pip,就能自动更新关联到你虚拟环境内的pip啦。
conda install pip
- 如果原始路径下还有pip的需求,再单独在环境外安装下pip.
边栏推荐
- Simple solution of regular expression
- AcWing 1986. 镜子(模拟,环图)
- Lambda expression | shallow solution
- Using stairs function in MATLAB
- Windows10 install mysql-8.0.28-winx64
- Clj3-100alh30 residual current relay
- UI自动化测试中比较少见的异常记录
- 2022-06-11:注意本文件中,graph不是邻接矩阵的含义,而是一个二部图。 在长度为N的邻接矩阵matrix中,所有的点有N个,matrix[i][j]
- Postman incoming list
- Unlimited growth, we will all go to the future | the 15th anniversary of the founding of InfoQ China
猜你喜欢

redis 总结

The reason why scanf return value is ignored and its solution

manuscript手稿格式准备

MySQL45讲 01 | 基础架构:一条SQL查询语句是如何执行的?

Relatively rare exception records in UI automation test

M-arch (fanwai 10) gd32l233 evaluation -spi drive DS1302

Index in MySQL show index from XXX the meaning of each parameter

Using stairs function in MATLAB

Logrotate log rotation method create and copyruncate principles

MySQL - built in function
随机推荐
NFT数字藏品的可验证性和稀缺性
A simple understanding of b+ tree
Don't swallow rice with vinegar! Teach you 2 moves to make the fish bones "run out" safely
Socket Programming TCP
Process creation and recycling
无限生长,我们都将奔赴未来 | InfoQ中国成立15周年
AcWing 1912. 里程表(枚举)
人類想要擁有金錢、權力、美麗、永生、幸福……但海龜只想做一只海龜
单元测试用例框架--unittest
AcWing 1912. Odometer (enumeration)
Zabbix 监控之LLD
C# 35. Select default network card
Deep learning and CV tutorial (14) | image segmentation (FCN, segnet, u-net, pspnet, deeplab, refinenet)
35. search insertion position
MySQL锁查漏补缺
FormatConversionTool. exe
Arm cross compilation chain download address
^34作用域面试题
【clickhouse专栏】基础数据类型说明
^33 variable promotion and function promotion interview questions
