for external in metadata.entry_points().get(self.group, []): Traceback (most recent call last): File "D:/Desktop/deepLearn/policy-gradient-tensoflow2.0-master/策略梯度_算法原生实现.py", line 4, in <module> import gym File "D:\DevTools\Anaconda3-5.2.0\envs\tf2\lib\site-packages\gym\__init__.py", line 13, in <module> from gym.envs import make, spec, register File "D:\DevTools\Anaconda3-5.2.0\envs\tf2\lib\site-packages\gym\envs\__init__.py", line 10, in <module> _load_env_plugins() File "D:\DevTools\Anaconda3-5.2.0\envs\tf2\lib\site-packages\gym\envs\registration.py", line 269, in load_env_plugins context = contextlib.nullcontext() AttributeError: module 'contextlib' has no attribute 'nullcontext'
时间: 2023-06-30 12:12:41 浏览: 75
这个错误是因为您的 Python 版本太低,`contextlib.nullcontext` 函数在 Python 3.6 及以下版本中不存在。
解决方法是升级您的 Python 版本至 Python 3.7 或以上版本。如果您无法升级 Python 版本,也可以手动添加 `nullcontext` 函数定义,如下:
```python
import contextlib
if not hasattr(contextlib, 'nullcontext'):
class nullcontext(contextlib.AbstractContextManager):
def __init__(self, enter_result=None):
self.enter_result = enter_result
def __enter__(self):
return self.enter_result
def __exit__(self, *excinfo):
pass
contextlib.nullcontext = nullcontext
```
添加了上述代码后,您的代码应该就可以正常运行了。
相关问题
oracle中,dbms_metadata.get_ddl使用技巧,举例说明
`DBMS_METADATA.GET_DDL`是Oracle中的一个函数,可以用于获取指定数据库对象的DDL语句。以下是使用`DBMS_METADATA.GET_DDL`的一些技巧:
1. 获取表的DDL语句:
```sql
SELECT DBMS_METADATA.GET_DDL('TABLE', 'TABLE_NAME') FROM DUAL;
```
其中,`TABLE_NAME`是需要获取DDL语句的表名。
2. 获取视图的DDL语句:
```sql
SELECT DBMS_METADATA.GET_DDL('VIEW', 'VIEW_NAME') FROM DUAL;
```
其中,`VIEW_NAME`是需要获取DDL语句的视图名。
3. 获取存储过程的DDL语句:
```sql
SELECT DBMS_METADATA.GET_DDL('PROCEDURE', 'PROCEDURE_NAME') FROM DUAL;
```
其中,`PROCEDURE_NAME`是需要获取DDL语句的存储过程名。
4. 批量获取多个对象的DDL语句:
```sql
SELECT DBMS_METADATA.GET_DDL('TABLE', table_name) FROM user_tables;
```
以上示例代码中,将`DBMS_METADATA.GET_DDL`函数与`SELECT`语句和相关的对象名称或数据字典视图结合使用,可以方便地获取Oracle数据库中各种对象的DDL语句。
in some cases result in small but subtle issues and is discouraged. import numpy as np Traceback (most recent call last): File "D:/Desktop/dql/a.py", line 1, in <module> import gym File "D:\DevTools\Anaconda3-5.2.0\envs\dql\lib\site-packages\gym\__init__.py", line 13, in <module> from gym.envs import make, spec, register File "D:\DevTools\Anaconda3-5.2.0\envs\dql\lib\site-packages\gym\envs\__init__.py", line 10, in <module> _load_env_plugins() File "D:\DevTools\Anaconda3-5.2.0\envs\dql\lib\site-packages\gym\envs\registration.py", line 250, in load_env_plugins for plugin in metadata.entry_points().get(entry_point, []): AttributeError: 'EntryPoints' object has no attribute 'get'
Based on the error message, it seems that there is an issue with the gym package in your Python environment. The error message suggests that there is a problem with an 'EntryPoints' object not having the 'get' attribute. This may be caused by a version incompatibility or a missing dependency.
You can try to resolve this issue by updating the gym package and any dependencies it may have. You can do this by running the following command in your terminal:
```
pip install --upgrade gym
```
If this does not work, you can also try to uninstall and then reinstall the gym package:
```
pip uninstall gym
pip install gym
```
If neither of these solutions work, you may need to investigate further or seek help from the gym community.