美文网首页Python3自学 爬虫实战
Python2和Python3共存的设置方法

Python2和Python3共存的设置方法

作者: 麦口胡 | 来源:发表于2017-08-27 15:04 被阅读0次

问题描述:python2运行正常的模块在python3中无法找到。

比如模块pymongo在python2运行正常。安装python3后,pip install pymongo后,在python3中 import pymongo时提示无法找到该模块。

问题原因:

pip install 未指定在哪个python环境中运行。

解决方法:

1、用各自的环境安装pip
python3 -m pip install --upgrade pip --force-reinstall
python2 -m pip install --upgrade pip --force-reinstall

2、再各自安装对应的模块,比如安装pymongo
python3 -m pip install pymongo
或者
pip3 install pymongo
pip install pymongo

相关文章

网友评论

    本文标题:Python2和Python3共存的设置方法

    本文链接:https://www.haomeiwen.com/subject/omnbdxtx.html