Python 无法安装 boto3
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/33388555/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Unable to install boto3
提问by Prabhakar Shanmugam
I have trouble installing boto3 inside a virtual environment.
我在虚拟环境中安装 boto3 时遇到问题。
I have done what the document says. First I activated virtual environment. then I did a:
我已经按照文件说的做了。首先我激活了虚拟环境。然后我做了一个:
Sudo pip install boto3
Now I enter python
现在我输入python
>> import boto3
ImportError: No module named boto3
But if I import boto, it works
但是如果我导入 boto,它会起作用
>> import boto
>> boto.Version
'2.38.0'
Why does it install boto 2.38 when I installed boto3. I tried closing the terminal and re-opened it. Should I restart the Ubuntu machine?
为什么在我安装 boto3 时安装了 boto 2.38。我尝试关闭终端并重新打开它。我应该重新启动 Ubuntu 机器吗?
采纳答案by Leistungsabfall
Don't use sudo
in a virtual environment because it ignores the environment's variables and therefore sudo pip
refers to your globalpip installation.
不要sudo
在虚拟环境中使用,因为它会忽略环境变量,因此会sudo pip
引用您的全局pip 安装。
So with your environment activated, rerun pip install boto3
but without sudo.
因此,在您的环境激活后,重新运行pip install boto3
但不使用 sudo。
回答by CasualT
There is another possible scenario that might get some people as well (if you have python and python3 on your system):
还有另一种可能的情况也可能会吸引一些人(如果您的系统上有 python 和 python3):
pip3 install boto3
pip3 install boto3
*note pip3
vs just pip
*注意pip3
与只是pip
回答by schmitt
I had a similar problem, but the accepted answer did not resolve it - I was not using a virtual environment. This is what I had to do:
我有一个类似的问题,但接受的答案并没有解决它 - 我没有使用虚拟环境。这就是我必须做的:
sudo python -m pip install boto3
I do not know why this behaved differently from sudo pip install boto3
.
我不知道为什么这与sudo pip install boto3
.
回答by sib10
I have faced the same issue and also not using virtual environment. easy_install is working for me.
我遇到了同样的问题,也没有使用虚拟环境。easy_install 对我有用。
easy_install boto3
回答by Paulo Victor
Do not run as sudo, just type:
不要以 sudo 身份运行,只需键入:
pip3 install boto3==1.7.40 --user
pip3 install boto3==1.7.40 --user
Enjoy
享受
回答by Tushar Niras
try this way:
试试这个方法:
python -m pip install --user boto3
回答by user10965163
Try this it works sudo apt install python-pip pip install boto3
试试这个它有效 sudo apt install python-pip pip install boto3
回答by nmakb
Though this is an old post, I am posting how I resolved in case it helps others. Since I used sudo to do the install of the boto3 library the permissions on the boto3 directory was set to 700. Either change the permissions to be readable by others or run the python command as sudo.
虽然这是一篇旧帖子,但我会发布我的解决方法,以防它对其他人有所帮助。因为我使用 sudo 来安装 boto3 库,所以 boto3 目录的权限设置为 700。要么将权限更改为其他人可读,要么以 sudo 身份运行 python 命令。