[英]How to install mesa (python package) for use in python 3
I have installed mesa via: 我通过以下方式安装了台面:
$ pip install mesa
but it is automatically installing it into 但它会自动将其安装到
/Users/MyName/Documents/User/lib/python2.7/site-packages/mesa/~
which means that when I try to run it with a Python 3 kernel, it can't find the module and I receive the error 这意味着当我尝试使用Python 3内核运行它时,找不到模块,并且收到错误消息
ModuleNotFoundError: No module named 'mesa'
Could someone help me out? 有人可以帮我吗? I'm assuming the problem is that it is automatically installed into the python 2.7 directory - how can i change this?
我假设问题是它会自动安装到python 2.7目录中-我该如何更改呢?
Thanks 谢谢
To install packages for Python3 while exists Python2, 要在存在Python2的情况下为Python3安装软件包,
try this 尝试这个
python3 -m pip install xxx
or this 或这个
sudo apt install pip3
pip3 install xxx
You should use pip3
instead of pip
: 您应该使用
pip3
而不是pip
:
pip3 install mesa
If you don't have pip3
install it using: 如果您没有
pip3
请使用以下pip3
安装:
sudo apt-get update
sudo apt-get -y install python3-pip
If it doesn't work you can do it manually using curl
: 如果它不起作用,您可以使用
curl
手动进行操作:
curl "https://bootstrap.pypa.io/get-pip.py" -o "get-pip.py"
python get-pip.py
You can also execute it straight from python3
: 您也可以直接从
python3
执行它:
python3 -m pip install mesa
It is always a good practice to set pip
command to be equivalent to your python
command. 将
pip
命令设置为等效于python
命令始终是一个好习惯。 ie, if python
points to python3
, you better change pip
to point to pip3
. 即,如果
python
指向python3
,则最好将pip
更改为指向pip3
。 Add alias pip='pip3'
to your ~/.bash_profile
file. 将
alias pip='pip3'
添加到您的~/.bash_profile
文件中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.