问题描述
在我的MacOS Mojave终端中,我想使用pip安装python软件包.最后说:
In my MacOS Mojave terminal I wanted to install a python package with pip. At the end it says:
You are using pip version 10.0.1, however version 18.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
所以我想用给定的命令更新点子,但出现错误:
So I wanted to update pip with the given command but I got an error:
Could not install packages due to an EnvironmentError: [Errno 13] Permission denied:
'/Library/Python/2.7/site-packages/pip-18.0-py2.7.egg/EGG-INFO/PKG-INFO'
Consider using the `--user` option or check the permissions.
我真的不知道现在该怎么办. 我也意识到它在错误消息中说Python 2.7,但是我已经并且只想使用python 3.
I don't really understand what to do now. Also I realized it says Python 2.7 in the error message but I have and want to use only python 3.
推荐答案
如果要使用 python3 + 安装软件包,则需要使用pip3 install packageName
If you want to use python3+ to install the packages you need to use pip3 install packageName
要解决 errno 13 ,您必须在末尾添加--user
And to solve the errno 13 you have to add --user
at the end
pip3 install packageName --user
对于python中的任何项目,强烈建议 使用 虚拟环境 是一种工具,可通过为它们创建隔离的python虚拟环境来帮助将不同项目所需的依赖项分开.
For any project in python it's highly recommended to work on a Virtual enviroment, is a tool that helps to keep dependencies required by different projects separate by creating isolated python virtual environments for them.
要使用 python3 + 创建一个,必须使用以下命令:
In order to create one with python3+ you have to use the following command:
virtualenv enviroment_name -p python3
然后您可以通过激活对其进行处理:
And then you work on it just by activating it:
source enviroment_name/bin/activate
激活虚拟环境后,虚拟环境的名称将出现在终端的左侧.这将使您知道虚拟环境当前处于活动状态.现在,您只需使用pip
,就可以在此虚拟环境中安装与项目相关的依赖项.
Once the virtual environment is activated, the name of your virtual environment will appear on left side of terminal. This will let you know that the virtual environment is currently active.Now you can install dependencies related to the project in this virtual environment by just using pip
.
pip install package_name
这篇关于由于环境错误而无法安装软件包:[Errno 13]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!