虚拟机Ubuntu16.04系统安装PyBullet并实现成功运行官方给出的示例

虚拟机软件:VirtualBox

虚拟操作系统版本:Ubuntu16.04LTS

安装参考:https://github.com/bulletphysics/bullet3/blob/master/README.md

虚拟机Ubuntu16.04系统安装PyBullet并实现成功运行官方给出的示例_第1张图片


安装pybullet-3.2.5

pip3 install pybullet --upgrade --user

虚拟机Ubuntu16.04系统安装PyBullet并实现成功运行官方给出的示例_第2张图片

        安装非常简单,已经顺利安装pybullet-3.2.5。下面运行一下,给定的三个样例吧。

测试官方例子

解决报错ImportError: No module named 'gym'

python3 -m pybullet_envs.examples.enjoy_TF_AntBulletEnv_v0_2017may

虚拟机Ubuntu16.04系统安装PyBullet并实现成功运行官方给出的示例_第3张图片

python3 -m pybullet_envs.examples.enjoy_TF_HumanoidFlagrunHarderBulletEnv_v1_2017jul

        报错ImportError: No module named 'gym'的解决方案,安装gym,输入命令

pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple gym

        再次运行

python3 -m pybullet_envs.examples.enjoy_TF_HumanoidFlagrunHarderBulletEnv_v1_2017jul

        很显然,报错ImportError: No module named 'gym'的问题已经解决。但是,发现出现了新的报错问题:

Failed to create GL 3.3 context ... using old-style GLX context

error: GLSL 1.50 is not supported. Supported versions are: 1.10, 1.20,and1.00 ES

解决报错 error: GLSL 1.50 is not supported. Supported versions are: 1.10, 1.20,and1.00 ES

虚拟机Ubuntu16.04系统安装PyBullet并实现成功运行官方给出的示例_第4张图片

 解决方案:

        关闭虚拟机,点击【显示】-->【屏幕】,取消勾选硬件加速:启用3D加速。

虚拟机Ubuntu16.04系统安装PyBullet并实现成功运行官方给出的示例_第5张图片

        打开虚拟机,再次输入

python3 -m pybullet_envs.examples.enjoy_TF_HumanoidFlagrunHarderBulletEnv_v1_2017jul

虚拟机Ubuntu16.04系统安装PyBullet并实现成功运行官方给出的示例_第6张图片

        成功啦!再来看下一个

python3 -m pybullet_envs.examples.enjoy_TF_AntBulletEnv_v0_2017may

虚拟机Ubuntu16.04系统安装PyBullet并实现成功运行官方给出的示例_第7张图片

         同样成功!继续

python3 -m pybullet_envs.deep_mimic.testrl --arg_file run_humanoid3d_backflip_args.txt

虚拟机Ubuntu16.04系统安装PyBullet并实现成功运行官方给出的示例_第8张图片

 报错ImportError: No module named 'tensorflow',解决方案,安装tensorflow,输入

pip3 install tensorflow

结果是

zlj@zlj-VirtualBox:~$ pip3 --default-timeout=1000 install matplotlib
DEPRECATION: Python 3.5 reached the end of its life on September 13th, 2020. Please upgrade your Python as Python 3.5 is no longer maintained. pip 21.0 will drop support for Python 3.5 in January 2021. pip 21.0 will remove support for this functionality.
Defaulting to user installation because normal site-packages is not writeable
Collecting matplotlib
  Downloading matplotlib-3.0.3-cp35-cp35m-manylinux1_x86_64.whl (13.0 MB)
     |████████████████████████████████| 13.0 MB 4.4 MB/s 
Collecting kiwisolver>=1.0.1
  Downloading kiwisolver-1.1.0-cp35-cp35m-manylinux1_x86_64.whl (90 kB)
     |████████████████████████████████| 90 kB 3.2 MB/s 
Collecting cycler>=0.10
  Downloading cycler-0.10.0-py2.py3-none-any.whl (6.5 kB)
Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in /usr/lib/python3/dist-packages (from matplotlib) (2.0.3)
Collecting python-dateutil>=2.1
  Downloading python_dateutil-2.8.2-py2.py3-none-any.whl (247 kB)
     |████████████████████████████████| 247 kB 10.3 MB/s 
Requirement already satisfied: numpy>=1.10.0 in ./.local/lib/python3.5/site-packages (from matplotlib) (1.18.5)
Requirement already satisfied: six in /usr/lib/python3/dist-packages (from cycler>=0.10->matplotlib) (1.10.0)
Requirement already satisfied: setuptools in /usr/lib/python3/dist-packages (from kiwisolver>=1.0.1->matplotlib) (20.7.0)
Installing collected packages: python-dateutil, kiwisolver, cycler, matplotlib
Successfully installed cycler-0.10.0 kiwisolver-1.1.0 matplotlib-3.0.3 python-dateutil-2.8.2
zlj@zlj-VirtualBox:~$ pip3 install tensorflow
DEPRECATION: Python 3.5 reached the end of its life on September 13th, 2020. Please upgrade your Python as Python 3.5 is no longer maintained. pip 21.0 will drop support for Python 3.5 in January 2021. pip 21.0 will remove support for this functionality.
Defaulting to user installation because normal site-packages is not writeable
Collecting tensorflow
  Downloading tensorflow-2.3.1-cp35-cp35m-manylinux2010_x86_64.whl (320.4 MB)
     |████████████████████████████████| 320.4 MB 8.2 kB/s 
Collecting gast==0.3.3
  Downloading gast-0.3.3-py2.py3-none-any.whl (9.7 kB)
Collecting keras-preprocessing<1.2,>=1.1.1
  Downloading Keras_Preprocessing-1.1.2-py2.py3-none-any.whl (42 kB)
     |████████████████████████████████| 42 kB 1.0 MB/s 
Collecting protobuf>=3.9.2
  Downloading protobuf-3.19.4-py2.py3-none-any.whl (162 kB)
     |████████████████████████████████| 162 kB 5.0 MB/s 
Collecting tensorboard<3,>=2.3.0
  Downloading tensorboard-2.5.0-py3-none-any.whl (6.0 MB)
     |████████████████████████████████| 6.0 MB 1.3 MB/s 
Collecting tensorflow-estimator<2.4.0,>=2.3.0
  Downloading tensorflow_estimator-2.3.0-py2.py3-none-any.whl (459 kB)
     |████████████████████████████████| 459 kB 1.8 MB/s 
Collecting absl-py>=0.7.0
  Downloading absl_py-0.15.0-py3-none-any.whl (132 kB)
     |████████████████████████████████| 132 kB 6.9 MB/s 
Collecting astunparse==1.6.3
  Downloading astunparse-1.6.3-py2.py3-none-any.whl (12 kB)
Collecting termcolor>=1.1.0
  Downloading termcolor-1.1.0.tar.gz (3.9 kB)
Collecting wrapt>=1.11.1
  Downloading wrapt-1.14.1-cp35-cp35m-manylinux2010_x86_64.whl (79 kB)
     |████████████████████████████████| 79 kB 2.2 MB/s 
Requirement already satisfied: numpy<1.19.0,>=1.16.0 in ./.local/lib/python3.5/site-packages (from tensorflow) (1.18.5)
Collecting opt-einsum>=2.3.2
  Downloading opt_einsum-3.3.0-py3-none-any.whl (65 kB)
     |████████████████████████████████| 65 kB 1.6 MB/s 
Collecting six>=1.12.0
  Downloading six-1.16.0-py2.py3-none-any.whl (11 kB)
Requirement already satisfied: wheel>=0.26 in /usr/lib/python3/dist-packages (from tensorflow) (0.29.0)
Collecting grpcio>=1.8.6
  Downloading grpcio-1.41.1.tar.gz (21.2 MB)
     |████████████████████████████████| 21.2 MB 1.5 MB/s 
Collecting h5py<2.11.0,>=2.10.0
  Downloading h5py-2.10.0-cp35-cp35m-manylinux1_x86_64.whl (2.8 MB)
     |████████████████████████████████| 2.8 MB 706 kB/s 
Collecting google-pasta>=0.1.8
  Downloading google_pasta-0.2.0-py3-none-any.whl (57 kB)
     |████████████████████████████████| 57 kB 3.4 MB/s 
Ignoring futures: markers 'python_version < "3.2"' don't match your environment
Ignoring enum34: markers 'python_version < "3.4"' don't match your environment
Collecting requests<3,>=2.21.0
  Downloading requests-2.25.1-py2.py3-none-any.whl (61 kB)
     |████████████████████████████████| 61 kB 1.4 MB/s 
Collecting google-auth<2,>=1.6.3
  Downloading google_auth-1.23.0-py2.py3-none-any.whl (114 kB)
     |████████████████████████████████| 114 kB 5.5 MB/s 
Collecting tensorboard<3,>=2.3.0
  Downloading tensorboard-2.4.1-py3-none-any.whl (10.6 MB)
     |████████████████████████████████| 10.6 MB 889 kB/s 
Collecting markdown>=2.6.8
  Downloading Markdown-3.2.2-py3-none-any.whl (88 kB)
     |████████████████████████████████| 88 kB 5.1 MB/s 
Collecting tensorboard-plugin-wit>=1.6.0
  Downloading tensorboard_plugin_wit-1.8.1-py3-none-any.whl (781 kB)
     |████████████████████████████████| 781 kB 7.1 MB/s 
Collecting werkzeug>=0.11.15
  Downloading Werkzeug-1.0.1-py2.py3-none-any.whl (298 kB)
     |████████████████████████████████| 298 kB 9.1 MB/s 
Collecting google-auth-oauthlib<0.5,>=0.4.1
  Downloading google_auth_oauthlib-0.4.1-py2.py3-none-any.whl (18 kB)
Collecting setuptools>=41.0.0
  Downloading setuptools-50.3.2-py3-none-any.whl (785 kB)
     |████████████████████████████████| 785 kB 3.1 MB/s 
Collecting rsa<5,>=3.1.4
  Downloading rsa-4.7.2-py3-none-any.whl (34 kB)
Collecting cachetools<5.0,>=2.0.0
  Downloading cachetools-4.2.4-py3-none-any.whl (10 kB)
Collecting pyasn1-modules>=0.2.1
  Downloading pyasn1_modules-0.2.8-py2.py3-none-any.whl (155 kB)
     |████████████████████████████████| 155 kB 9.1 MB/s 
Collecting requests-oauthlib>=0.7.0
  Downloading requests_oauthlib-1.3.1-py2.py3-none-any.whl (23 kB)
Collecting importlib-metadata
  Downloading importlib_metadata-2.1.3-py2.py3-none-any.whl (10 kB)
Collecting pyasn1<0.5.0,>=0.4.6
  Downloading pyasn1-0.4.8-py2.py3-none-any.whl (77 kB)
     |████████████████████████████████| 77 kB 3.6 MB/s 
Collecting idna<3,>=2.5
  Downloading idna-2.10-py2.py3-none-any.whl (58 kB)
     |████████████████████████████████| 58 kB 5.6 MB/s 
Collecting urllib3<1.27,>=1.21.1
  Downloading urllib3-1.26.9-py2.py3-none-any.whl (138 kB)
     |████████████████████████████████| 138 kB 11.1 MB/s 
Collecting certifi>=2017.4.17
  Downloading certifi-2021.10.8-py2.py3-none-any.whl (149 kB)
     |████████████████████████████████| 149 kB 15.2 MB/s 
Collecting chardet<5,>=3.0.2
  Downloading chardet-4.0.0-py2.py3-none-any.whl (178 kB)
     |████████████████████████████████| 178 kB 6.1 MB/s 
Collecting oauthlib>=3.0.0
  Downloading oauthlib-3.1.0-py2.py3-none-any.whl (147 kB)
     |████████████████████████████████| 147 kB 11.1 MB/s 
Collecting zipp>=0.5
  Downloading zipp-1.2.0-py2.py3-none-any.whl (4.8 kB)
Building wheels for collected packages: grpcio, termcolor
  Building wheel for grpcio (setup.py) ... done
  Created wheel for grpcio: filename=grpcio-1.41.1-cp35-cp35m-linux_x86_64.whl size=37151701 sha256=54d2560339373cf36bdfd46d0fe2612a8daf7219f68fa0ea404b3308bdb31b7a
  Stored in directory: /home/zlj/.cache/pip/wheels/3f/79/8e/2aa88c6daffd594ac957c188bb161d034e49ac39e535ea8be4
  Building wheel for termcolor (setup.py) ... done
  Created wheel for termcolor: filename=termcolor-1.1.0-py3-none-any.whl size=5680 sha256=2b4d7cc5fdf2803c6bb70f8b713b5359444311fba8af9322cf429e40f42dedc2
  Stored in directory: /home/zlj/.cache/pip/wheels/91/0e/11/1f1321dce76e9c542907008e4a94ff79f8bf525a3fa32b09f3
Successfully built grpcio termcolor
Installing collected packages: urllib3, pyasn1, idna, chardet, certifi, zipp, six, setuptools, rsa, requests, pyasn1-modules, oauthlib, cachetools, requests-oauthlib, importlib-metadata, google-auth, werkzeug, tensorboard-plugin-wit, protobuf, markdown, grpcio, google-auth-oauthlib, absl-py, wrapt, termcolor, tensorflow-estimator, tensorboard, opt-einsum, keras-preprocessing, h5py, google-pasta, gast, astunparse, tensorflow
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
grpcio 1.41.1 requires enum34>=1.0.4, which is not installed.
grpcio 1.41.1 requires futures>=2.2.0, which is not installed.
Successfully installed absl-py-0.15.0 astunparse-1.6.3 cachetools-4.2.4 certifi-2021.10.8 chardet-4.0.0 gast-0.3.3 google-auth-1.23.0 google-auth-oauthlib-0.4.1 google-pasta-0.2.0 grpcio-1.41.1 h5py-2.10.0 idna-2.10 importlib-metadata-2.1.3 keras-preprocessing-1.1.2 markdown-3.2.2 oauthlib-3.1.0 opt-einsum-3.3.0 protobuf-3.19.4 pyasn1-0.4.8 pyasn1-modules-0.2.8 requests-2.25.1 requests-oauthlib-1.3.1 rsa-4.7.2 setuptools-50.3.2 six-1.16.0 tensorboard-2.4.1 tensorboard-plugin-wit-1.8.1 tensorflow-2.3.1 tensorflow-estimator-2.3.0 termcolor-1.1.0 urllib3-1.26.9 werkzeug-1.0.1 wrapt-1.14.1 zipp-1.2.0

报错

ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
grpcio 1.41.1 requires enum34>=1.0.4, which is not installed.
grpcio 1.41.1 requires futures>=2.2.0, which is not installed.

        解决方法,重新安装两个版本冲突的包enum34和futures。第一步,安装enum34,输入

pip3 install enum34

虚拟机Ubuntu16.04系统安装PyBullet并实现成功运行官方给出的示例_第9张图片

        可以看到已经成功安装enum34-1.1.10,符合>=1.0.4的要求。此时仍存在报错(在预想范围,第二步会重新下载或升级futures

ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
grpcio 1.41.1 requires futures>=2.2.0, which is not installed.

        第二步,安装futures,输入

pip3 install futures

虚拟机Ubuntu16.04系统安装PyBullet并实现成功运行官方给出的示例_第10张图片

        我们可以推知,此时应该已经满足TensorFlow所有的版本要求了,我们测试一下,果然如此

zlj@zlj-VirtualBox:~$ pip3 install tensorflow
DEPRECATION: Python 3.5 reached the end of its life on September 13th, 2020. Please upgrade your Python as Python 3.5 is no longer maintained. pip 21.0 will drop support for Python 3.5 in January 2021. pip 21.0 will remove support for this functionality.
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: tensorflow in ./.local/lib/python3.5/site-packages (2.3.1)
Requirement already satisfied: termcolor>=1.1.0 in ./.local/lib/python3.5/site-packages (from tensorflow) (1.1.0)
Requirement already satisfied: tensorflow-estimator<2.4.0,>=2.3.0 in ./.local/lib/python3.5/site-packages (from tensorflow) (2.3.0)
Requirement already satisfied: grpcio>=1.8.6 in ./.local/lib/python3.5/site-packages (from tensorflow) (1.41.1)
Requirement already satisfied: absl-py>=0.7.0 in ./.local/lib/python3.5/site-packages (from tensorflow) (0.15.0)
Requirement already satisfied: six>=1.12.0 in ./.local/lib/python3.5/site-packages (from tensorflow) (1.16.0)
Requirement already satisfied: h5py<2.11.0,>=2.10.0 in ./.local/lib/python3.5/site-packages (from tensorflow) (2.10.0)
Requirement already satisfied: opt-einsum>=2.3.2 in ./.local/lib/python3.5/site-packages (from tensorflow) (3.3.0)
Requirement already satisfied: keras-preprocessing<1.2,>=1.1.1 in ./.local/lib/python3.5/site-packages (from tensorflow) (1.1.2)
Requirement already satisfied: astunparse==1.6.3 in ./.local/lib/python3.5/site-packages (from tensorflow) (1.6.3)
Requirement already satisfied: numpy<1.19.0,>=1.16.0 in ./.local/lib/python3.5/site-packages (from tensorflow) (1.18.5)
Requirement already satisfied: tensorboard<3,>=2.3.0 in ./.local/lib/python3.5/site-packages (from tensorflow) (2.4.1)
Requirement already satisfied: google-pasta>=0.1.8 in ./.local/lib/python3.5/site-packages (from tensorflow) (0.2.0)
Requirement already satisfied: protobuf>=3.9.2 in ./.local/lib/python3.5/site-packages (from tensorflow) (3.19.4)
Requirement already satisfied: wheel>=0.26 in /usr/lib/python3/dist-packages (from tensorflow) (0.29.0)
Requirement already satisfied: gast==0.3.3 in ./.local/lib/python3.5/site-packages (from tensorflow) (0.3.3)
Requirement already satisfied: wrapt>=1.11.1 in ./.local/lib/python3.5/site-packages (from tensorflow) (1.14.1)
Requirement already satisfied: futures>=2.2.0 in ./.local/lib/python3.5/site-packages (from grpcio>=1.8.6->tensorflow) (3.0.5)
Requirement already satisfied: enum34>=1.0.4 in ./.local/lib/python3.5/site-packages (from grpcio>=1.8.6->tensorflow) (1.1.10)
Requirement already satisfied: requests<3,>=2.21.0 in ./.local/lib/python3.5/site-packages (from tensorboard<3,>=2.3.0->tensorflow) (2.25.1)
Requirement already satisfied: markdown>=2.6.8 in ./.local/lib/python3.5/site-packages (from tensorboard<3,>=2.3.0->tensorflow) (3.2.2)
Requirement already satisfied: werkzeug>=0.11.15 in ./.local/lib/python3.5/site-packages (from tensorboard<3,>=2.3.0->tensorflow) (1.0.1)
Requirement already satisfied: setuptools>=41.0.0 in ./.local/lib/python3.5/site-packages (from tensorboard<3,>=2.3.0->tensorflow) (50.3.2)
Requirement already satisfied: google-auth<2,>=1.6.3 in ./.local/lib/python3.5/site-packages (from tensorboard<3,>=2.3.0->tensorflow) (1.23.0)
Requirement already satisfied: tensorboard-plugin-wit>=1.6.0 in ./.local/lib/python3.5/site-packages (from tensorboard<3,>=2.3.0->tensorflow) (1.8.1)
Requirement already satisfied: google-auth-oauthlib<0.5,>=0.4.1 in ./.local/lib/python3.5/site-packages (from tensorboard<3,>=2.3.0->tensorflow) (0.4.1)
Requirement already satisfied: rsa<5,>=3.1.4 in ./.local/lib/python3.5/site-packages (from google-auth<2,>=1.6.3->tensorboard<3,>=2.3.0->tensorflow) (4.7.2)
Requirement already satisfied: cachetools<5.0,>=2.0.0 in ./.local/lib/python3.5/site-packages (from google-auth<2,>=1.6.3->tensorboard<3,>=2.3.0->tensorflow) (4.2.4)
Requirement already satisfied: pyasn1-modules>=0.2.1 in ./.local/lib/python3.5/site-packages (from google-auth<2,>=1.6.3->tensorboard<3,>=2.3.0->tensorflow) (0.2.8)
Requirement already satisfied: requests-oauthlib>=0.7.0 in ./.local/lib/python3.5/site-packages (from google-auth-oauthlib<0.5,>=0.4.1->tensorboard<3,>=2.3.0->tensorflow) (1.3.1)
Requirement already satisfied: importlib-metadata in ./.local/lib/python3.5/site-packages (from markdown>=2.6.8->tensorboard<3,>=2.3.0->tensorflow) (2.1.3)
Requirement already satisfied: pyasn1<0.5.0,>=0.4.6 in ./.local/lib/python3.5/site-packages (from pyasn1-modules>=0.2.1->google-auth<2,>=1.6.3->tensorboard<3,>=2.3.0->tensorflow) (0.4.8)
Requirement already satisfied: chardet<5,>=3.0.2 in ./.local/lib/python3.5/site-packages (from requests<3,>=2.21.0->tensorboard<3,>=2.3.0->tensorflow) (4.0.0)
Requirement already satisfied: idna<3,>=2.5 in ./.local/lib/python3.5/site-packages (from requests<3,>=2.21.0->tensorboard<3,>=2.3.0->tensorflow) (2.10)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in ./.local/lib/python3.5/site-packages (from requests<3,>=2.21.0->tensorboard<3,>=2.3.0->tensorflow) (1.26.9)
Requirement already satisfied: certifi>=2017.4.17 in ./.local/lib/python3.5/site-packages (from requests<3,>=2.21.0->tensorboard<3,>=2.3.0->tensorflow) (2021.10.8)
Requirement already satisfied: oauthlib>=3.0.0 in ./.local/lib/python3.5/site-packages (from requests-oauthlib>=0.7.0->google-auth-oauthlib<0.5,>=0.4.1->tensorboard<3,>=2.3.0->tensorflow) (3.1.0)
Requirement already satisfied: zipp>=0.5 in ./.local/lib/python3.5/site-packages (from importlib-metadata->markdown>=2.6.8->tensorboard<3,>=2.3.0->tensorflow) (1.2.0)

        那么现在是时候再测试一下了,终端输入

python3 -m pybullet_envs.deep_mimic.testrl --arg_file run_humanoid3d_backflip_args.txt

        根据报错ImportError: No module named 'cloud_tpu_client',输入

pip3 install cloud_tpu_client

        可以看出,成功安装cloud-tpu-client-0.1。

        根据报错ImportError: No module named 'mpi4py',输入

pip3 install mpi4py

        可以看出,成功安装mpi4py-3.0.3。再运行一下,报错

b3Printf: b3Warning[examples/Importers/ImportURDFDemo/BulletUrdfImporter.cpp

tensorflow.python.framework.errors_impl.FailedPreconditionError: Error while reading resource variable agent/resource/s_norm/mean_ph from Container: localhost. This could mean that the variable was uninitialized. Not found: Container localhost does not exist. (Could not find resource: localhost/agent/resource/s_norm/mean_ph)
         [[{{node agent/resource/s_norm/ReadVariableOp_2}}]]

        可以显示一下界面,然后闪退。错误完全类似于

python - Error while running deepmimic example in pybullet with tensorflow - Stack Overflow

        题主使用的是python 3.8+tensorflow 2.3.1,解决方案说python 3.7+tensorflow 1.13可以正常工作。于是,我卸载了已经安装的tensorflow-2.3.1,重新安装了tensorflow1.15。之后,再次运行就正常啦!

pip3 install tensorflow==1.15

虚拟机Ubuntu16.04系统安装PyBullet并实现成功运行官方给出的示例_第11张图片

 


附录(虚拟机启用3D加速时):

        尝试查询OpenGL版本,输入 

glxinfo | grep "OpenGL version"

显示:程序“glxinfo”尚未安装。 您可以使用以下命令安装:sudo apt install mesa-utils
        按照提示,进行安装,输入

sudo apt install mesa-utils

        再次查询,输入

glxinfo | grep "OpenGL version"

虚拟机Ubuntu16.04系统安装PyBullet并实现成功运行官方给出的示例_第12张图片

        查询的结果是OpenGL version string: 2.1 Mesa 18.0.5。

你可能感兴趣的:(Ubuntu16.04LTS,ubuntu,linux,python)