Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/315.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
TypeError:JSON对象必须是str,而不是';字节';当使用bash shell执行时。当使用python解释器时,代码运行良好_Python_Python 3.x_Boto_Rds - Fatal编程技术网

TypeError:JSON对象必须是str,而不是';字节';当使用bash shell执行时。当使用python解释器时,代码运行良好

TypeError:JSON对象必须是str,而不是';字节';当使用bash shell执行时。当使用python解释器时,代码运行良好,python,python-3.x,boto,rds,Python,Python 3.x,Boto,Rds,我希望获得AWS环境中所有正在运行的实例。我正在使用python 3.3。 我之前使用过boto.rds,它有一个名为rds2.get_all_dbinstances()的方法。 但我现在正在迁移到rds2。当我尝试使用python解释器运行上述代码时用法:python filename.py:没有得到任何错误。程序运行良好。但是使用bashshell用法:./filename.py: 我得到一个错误: #!/usr/bin/env python3 import boto.rds2

我希望获得AWS环境中所有正在运行的实例。我正在使用python 3.3。 我之前使用过boto.rds,它有一个名为rds2.get_all_dbinstances()的方法。 但我现在正在迁移到rds2。当我尝试使用python解释器运行上述代码时用法:python filename.py:没有得到任何错误。程序运行良好。但是使用bashshell用法:./filename.py: 我得到一个错误:

#!/usr/bin/env python3    
import boto.rds2    
rds2_conn=boto.rds2.connect_to_region(region_name="us-east")
cs= rds2_conn.describe_db_instances(db_instance_identifier=None)
print(cs)
TypeError:File”/Users/heninkarkada/Documents/repositories/jaws/b.py”,第5行,在
raw=con.描述数据库实例(数据库实例标识符=None)
文件“/usr/local/lib/python3.4/site packages/boto/rds2/layer1.py”,第1512行,在descripe\u db\u实例中
路径=“/”,参数=参数)
文件“/usr/local/lib/python3.4/site packages/boto/rds2/layer1.py”,第3764行,在请求中
返回json.loads(body)
文件“/usr/local/cillar/python3/3.4.1_1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/json/__init__.py”,第312行,在loads中
s、 _u_类________;名称____;)
TypeError:JSON对象必须是str,而不是“bytes”。JSON对象必须是str,而不是第3行的“bytes”
有人能告诉我为什么会发生这种事吗? 提前感谢谢邦/如果脚本实际上是Python 2脚本,而不是Python 3脚本,则usr/bin/env python3可能不正确
json
接受Python 2中的ByTestRing。在Python3中,输入必须是Unicode字符串

失败的json代码在
boto
包中。
boto的
setup.py
声称支持Python3,但有可能。

您可以手动传递路径到
description\u db\u实例吗?如果是,请执行此操作,然后重新运行。我猜这与bash在python解释器传递本机str时传递bytestring有关。您可能需要检查您使用的是同一个python。是否
which python
which python3
指向相同的东西?@Logan-我正在尝试检索连接到特定区域的所有正在运行的dvu实例'@mgilson python shows-/usr/bin/python和python 3-/usr/local/bin/python3try
python3 filename.py
。它应该会产生同样的错误。
TypeError: File "/Users/heninkarkada/Documents/repositories/jaws/b.py", line 5, in <module>
    raw=con.describe_db_instances(db_instance_identifier=None)
  File "/usr/local/lib/python3.4/site-packages/boto/rds2/layer1.py", line 1512, in describe_db_instances
    path='/', params=params)
  File "/usr/local/lib/python3.4/site-packages/boto/rds2/layer1.py", line 3764, in _make_request
    return json.loads(body)
  File "/usr/local/Cellar/python3/3.4.1_1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/json/__init__.py", line 312, in loads
    s.__class__.__name__))
TypeError: the JSON object must be str, not 'bytes'the JSON object must be str, not 'bytes' at line no:3