使用pip安装Python模块 [英] Python module install with pip

查看:106
本文介绍了使用pip安装Python模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我曾经使用命令pip3 install module_name来安装任何模块,并且该模块正在运行.但是突然我尝试安装某些东西时出现以下错误.

I used to inuput the command pip3 install module_name to install any module and it was working. But suddenly I have the following error when I try to install something.

Traceback (most recent call last):
 File "/Library/Frameworks/Python.framework/Versions/3.7/bin/pip", line 10, in <module>
   sys.exit(main())
TypeError: 'module' object is not callable

有人知道为什么会发生此错误,请问如何解决?

Do somebody know why this error occurs and how I can solve it please?

推荐答案

您要使用python -m pip install <module>,因为python命令将利用特定的解释器.但是,pip本身可以指向任意数量的pip二进制文件,这些二进制文件可以指向未知的解释器.因此,最好的办法是指定解释器.

You want to use python -m pip install <module> because the python command will leverage a specific interpreter. However, pip by itself could point to any number of pip binaries, which could point to unknown interpreters. So, best thing to do is to specify the interpreter.

具体地说,-m标志指示我想从指定的python调用模块". pip不是您可以执行此操作的唯一模块:

Specifically, the -m flag says "I want to call a module from the python I have specified." pip is not the only module you can do this with:

python -m timeit
python -m zipfile
python -m pip

您可以使用-V标志检查pip指向的位置:

You can check where pip is pointing by using the -V flag:

python -m pip -V
pip 19.2.2 from /Users/mm92400/anaconda3/lib/python3.6/site-packages/pip (python 3.6)

这篇关于使用pip安装Python模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆