文章目录
python中使用pip安装模块的方法
pip安装模块命令:
python -m pip install 模块名
python -m pip install 模块名==模块版本号 # 指定版本号可安装特定版本的模块
如何知道我们的python模块安装到哪个位置
当我们在cmd.exe中运行Python.exe时,运行的Python是哪一个Python取决于我们的用户环境变量path中哪一个含有python.exe的路径在环境变量path的最前面,在cmd中输入python执行时总是执行path路径中第一个含有python.exe路径中的python.exe。
如果我们使用anaconda prompt,只要我们使用命令:
activate 环境名
python -m pip install 模块名
这时模块就会安装在上面activate的那个环境中。
Cannot uninstall X错误的解决方法
有时我们会遇到Cannot uninstall X这类错误,提示类似下面的代码:
Installing collected packages: numpy
Found existing installation: numpy 1.8.2
Cannot uninstall 'numpy'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.
出现这种错误的原因是我们在新安装B包时,以前安装的A包中含有一些B包中要安装的模块,而Python并不知道这些模块中是A包中的版本比较新还是B包中的版本比较新,所以选择中止安装。
我们可以使用命令:
pip install 模块名 --ignore-installed
来解决这个冲突,这样遇到已安装过的模块时就会跳过这个模块。
pip安装jupyter notebook以及在指定目录下打开jupyter notebook
pip安装jupyter notebook(请打开代理,有时可能下载不成功):
python -m pip