[英]How to install troposphere for python3?
I'm running macOS
version 11.0.1
.我正在运行
macOS
版本11.0.1
。 I'm trying to import a module called troposphere
I have Python2.7
as well as Python3.9.1
installed When I try to import troposphere using Python2.7
like我正在尝试导入一个名为
troposphere
的模块我安装了Python2.7
和Python3.9.1
当我尝试使用Python2.7
导入对流层时
#!/usr/bin/python
from troposphere import Template
It does work.它确实有效。 But when I try to import the same using
Python3.9.1
like但是当我尝试使用
Python3.9.1
导入相同的内容时
#!/usr/bin/python3
from troposphere import Template
It throws error like this它会抛出这样的错误
ModuleNotFoundError: No module named 'troposphere'
What should I do?我应该怎么办? Please help
请帮忙
Chek if the module was depreciated检查模块是否折旧
it is because the python interpreter you use to run your code doesn't have troposphere installed.这是因为您用于运行代码的 python 解释器没有安装对流层。
Managing multiple Python version on the same computer is tricky, But I will try to explain it.在同一台计算机上管理多个 Python 版本很棘手,但我会尝试解释一下。
I assume that you are using python your_script.py
to run your code, and pip install troposphere
to install package right?我假设您使用
python your_script.py
来运行您的代码,并pip install troposphere
来安装 package 对吗? But think of this, how does your system know exactly which python you are running and which python to install package?但是想想这个,你的系统怎么知道你在运行哪个 python 和哪个 python 安装 package? Here's how to check the full path of your python command and pip command.
这是检查 python 命令和 pip 命令的完整路径的方法。
python
command enter python consolepython
命令进入 python 控制台 import sys print(sys.executable)
bin/python
which is your interpreter and bin/pip
which is your pip command.
bin/python
这是你的解释器和bin/pip
这是你的 pip 命令。
And there's a lib/site-packages
folder, this is where third party library been installed to.
lib/site-packages
文件夹,这是安装第三方库的地方。
4. if you see import error, use the above method to locate the python interpreter and check the site-packages folder, most likely there's no such troposphere
folder in it.
troposphere
文件夹。
Then you need to use the full path of the <path-to>/bin/pip
to install troposphere.
<path-to>/bin/pip
的完整路径来安装对流层。
Then your problem is solved.
If you are using home brew or the python installer download from www.python.org , your system probablly already messed up.如果您使用的是自制软件或从www.python.org下载的 python 安装程序,那么您的系统可能已经搞砸了。 The recommended way to manage multiple Python version is to use pyenv https://github.com/pyenv/pyenv .
管理多个 Python 版本的推荐方法是使用 pyenv https://github.com/pyenv/pyenv 。 It allows you to install any python version and easy to delete them.
它允许您安装任何 python 版本并轻松删除它们。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.