Reference link:
Vmware Ubuntu kylin NAT mode Internet access settings_ Y4ung CSDN blog
Ubuntu 16.04 pure version - install Python 3.8.1/upgrade pip - Wang Yu - blog Park (cnblogs.com)
The virtual machine installation will not be repeated. The version used is ubuntu kylin-16.04-desktop-amd64 (it is recommended to use ubuntu instead of centos).
The installation process is easy and can be determined in sequence. After the installation, we need to configure the network to link our virtual machines to the network.
1, Configure network
1. Open VMware workstation, menu bar options – > Edit – > virtual network editor, set VMnet8 to NAT mode, and start DHCP(DHCP is used to dynamically allocate virtual machine IP, and it doesn't matter if it is not enabled), as shown in the figure:
2. Start NAT service and DHCP service on the host:
win+r –> services.msc
3. Then, open VMware workstation and set the menu bar option – > virtual machine – > to NAT mode
4. Change the adapter settings, set the network that can access the Internet as shared, and share it with VMnet8 of the virtual machine (do not check the following box):
2, Configuring the python 3 environment
ubuntu's kylin16 system brings its own Python 2.7 and python 3.5 environment. I need to use Python 3.8 +.
1. Configure the dependent environment. If this step is not performed, some problems may occur.
2. Go to the official website to download Python-3.8.1.tar.xz
3. Unzip the downloaded package
tar -xvJf Python-3.8.1.tar.xz
4. Enter the extracted directory
cd Python-3.8.1/
5. Install dependency (if not necessary, skip this step. If there is an error in step 6, execute this step)
Execute the following commands to install the dependenc y. If prompted, click OK.
sudo apt-get install python-dev sudo apt-get install libffi-dev sudo apt-get install libssl-dev sudo apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev
6. Perform installation
./configure prefix=/usr/local/python3 sudo make && sudo make install
7. Modify soft connection (configure global variables)
Back up the original link.
sudo mv /usr/bin/python /usr/bin/python.bak
Add a soft link to Python 3.
sudo ln -s /usr/local/python3/bin/python3 /usr/bin/python
Test whether the installation was successful.
python -V
8. Install / upgrade pip
Install PIP for Python 2.7
sudo apt-get install python-pip
Install pip for Python 3.
sudo apt-get install python3-pip
Perform the upgrade.
sudo pip install --upgrade pip sudo pip3 install --upgrade pip
There was a problem upgrading pip:
Traceback (most recent call last): File "/usr/bin/pip", line 9, in <module> from pip import main
Modify the pip configuration
sudo vi /usr/bin/pip
Change to
#Original PIP profile from pip import main if __name__ == '__main__': sys.exit(main()) #Change to from pip import __main__ //modify if __name__ == '__main__': sys.exit(__main__._main())//modify
9. There was a problem installing PIP3 package
Traceback (most recent call last): File "/usr/bin/pip3", line 11, in <module> sys.exit(main()) File "/home/fulequn/.local/lib/python3.5/site-packages/pip/__init__.py", line 11, in main from pip._internal.utils.entrypoints import _wrapper File "/home/fulequn/.local/lib/python3.5/site-packages/pip/_internal/utils/entrypoints.py", line 4, in <module> from pip._internal.cli.main import main File "/home/fulequn/.local/lib/python3.5/site-packages/pip/_internal/cli/main.py", line 57 sys.stderr.write(f"ERROR: {exc}")
reason
After checking a lot, most foreigners say that the higher version of pip is no longer supported python3.5
solve
Remove pip related files
sudo apt autoremove
Download the pip installation file
url -O https://bootstrap.pypa.io/pip/3.5/get-pip.py
Execute installation file
/usr/bin/python3 get-pip.py
Install PIP for Python 2.7
sudo apt-get install python-pip
Install pip for Python 3.
sudo apt-get install python3-pip
pip upgrade
sudo pip install --upgrade pip sudo pip3 install --upgrade pip
After I uninstall this part, there is an error that pip does not exist. Then reinstall and upgrade.
3, Install OpenAI gym
Enter the following statement to install gym
pip install gym -i https://pypi.tuna.tsinghua.edu.cn/simple
1. The following error occurred
ModuleNotFoundError: No module named '_ctypes'
solve:
sudo apt install libffi-dev -y
2. An error occurred
ERROR: No matching distribution found for gym[all]
Unresolved
3. An error occurred
ERROR: Command errored out with exit status 1: command: /usr/bin/python -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-n_xs68fh/mujoco-py_a3733903fc69448b995da4444e4157b9/setup.py'"'"'; __file__='"'"'/tmp/pip-install-n_xs68fh/mujoco-py_a3733903fc69448b995da4444e4157b9/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-cqfhnl92/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /home/fulequn/.local/include/python3.8/mujoco-py cwd: /tmp/pip-install-n_xs68fh/mujoco-py_a3733903fc69448b995da4444e4157b9/ Complete output (58 lines): running install /home/fulequn/.local/lib/python3.8/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools. warnings.warn( running build You appear to be missing MuJoCo. We expected to find the file here: /home/fulequn/.mujoco/mjpro150 This package only provides python bindings, the library must be installed separately. Please follow the instructions on the README to install MuJoCo https://github.com/openai/mujoco-py#install-mujoco Which can be downloaded from the website https://www.roboti.us/index.html Traceback (most recent call last): File "<string>", line 1, in <module> File "/tmp/pip-install-n_xs68fh/mujoco-py_a3733903fc69448b995da4444e4157b9/setup.py", line 32, in <module> setup( File "/home/fulequn/.local/lib/python3.8/site-packages/setuptools/__init__.py", line 153, in setup return distutils.core.setup(**attrs) File "/usr/local/python3/lib/python3.8/distutils/core.py", line 148, in setup dist.run_commands() File "/usr/local/python3/lib/python3.8/distutils/dist.py", line 966, in run_commands self.run_command(cmd) File "/usr/local/python3/lib/python3.8/distutils/dist.py", line 985, in run_command cmd_obj.run() File "/home/fulequn/.local/lib/python3.8/site-packages/setuptools/command/install.py", line 68, in run return orig.install.run(self) File "/usr/local/python3/lib/python3.8/distutils/command/install.py", line 545, in run self.run_command('build') File "/usr/local/python3/lib/python3.8/distutils/cmd.py", line 313, in run_command self.distribution.run_command(command) File "/usr/local/python3/lib/python3.8/distutils/dist.py", line 985, in run_command cmd_obj.run() File "/tmp/pip-install-n_xs68fh/mujoco-py_a3733903fc69448b995da4444e4157b9/setup.py", line 28, in run import mujoco_py # noqa: force build File "/tmp/pip-install-n_xs68fh/mujoco-py_a3733903fc69448b995da4444e4157b9/mujoco_py/__init__.py", line 3, in <module> from mujoco_py.builder import cymj, ignore_mujoco_warnings, functions, MujocoException File "/tmp/pip-install-n_xs68fh/mujoco-py_a3733903fc69448b995da4444e4157b9/mujoco_py/builder.py", line 502, in <module> mjpro_path, key_path = discover_mujoco() File "/tmp/pip-install-n_xs68fh/mujoco-py_a3733903fc69448b995da4444e4157b9/mujoco_py/utils.py", line 93, in discover_mujoco raise Exception(message) Exception: You appear to be missing MuJoCo. We expected to find the file here: /home/fulequn/.mujoco/mjpro150 This package only provides python bindings, the library must be installed separately. Please follow the instructions on the README to install MuJoCo https://github.com/openai/mujoco-py#install-mujoco Which can be downloaded from the website https://www.roboti.us/index.html ---------------------------------------- ERROR: Command errored out with exit status 1: /usr/bin/python -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-n_xs68fh/mujoco-py_a3733903fc69448b995da4444e4157b9/setup.py'"'"'; __file__='"'"'/tmp/pip-install-n_xs68fh/mujoco-py_a3733903fc69448b995da4444e4157b9/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-cqfhnl92/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /home/fulequn/.local/include/python3.8/mujoco-py Check the logs for full command output.
Unresolved