1e41f4b71Sopenharmony_ci# Fixing Compilation and Building Errors
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ci
4e41f4b71Sopenharmony_ci## "ImportError: No module named apt_pkg" is displayed during the execution of an unidentifiable command
5e41f4b71Sopenharmony_ci
6e41f4b71Sopenharmony_ci- **Symptom**
7e41f4b71Sopenharmony_ci  
8e41f4b71Sopenharmony_ci  The message "ImportError: No module named apt_pkg" is displayed when an unidentifiable command is executed on the Linux server.
9e41f4b71Sopenharmony_ci
10e41f4b71Sopenharmony_ci- **Possible Causes**
11e41f4b71Sopenharmony_ci  
12e41f4b71Sopenharmony_ci  There is a compatibility issue of python3-apt.
13e41f4b71Sopenharmony_ci
14e41f4b71Sopenharmony_ci- **Solution**
15e41f4b71Sopenharmony_ci  
16e41f4b71Sopenharmony_ci  Reinstall python3-apt.
17e41f4b71Sopenharmony_ci
18e41f4b71Sopenharmony_ci  
19e41f4b71Sopenharmony_ci  ```
20e41f4b71Sopenharmony_ci  sudo apt-get remove  python3-apt
21e41f4b71Sopenharmony_ci  sudo apt-get install python3-apt
22e41f4b71Sopenharmony_ci  ```
23e41f4b71Sopenharmony_ci
24e41f4b71Sopenharmony_ci
25e41f4b71Sopenharmony_ci## The message indicating Python cannot be found is displayed during the build process
26e41f4b71Sopenharmony_ci
27e41f4b71Sopenharmony_ci- **Symptom**
28e41f4b71Sopenharmony_ci
29e41f4b71Sopenharmony_ci  The following information is displayed during the build process:
30e41f4b71Sopenharmony_ci
31e41f4b71Sopenharmony_ci  
32e41f4b71Sopenharmony_ci  ```
33e41f4b71Sopenharmony_ci  -bash: /usr/bin/python: No such file or directory
34e41f4b71Sopenharmony_ci  ```
35e41f4b71Sopenharmony_ci
36e41f4b71Sopenharmony_ci- **Possible Cause 1**
37e41f4b71Sopenharmony_ci  
38e41f4b71Sopenharmony_ci  Python is not installed.
39e41f4b71Sopenharmony_ci
40e41f4b71Sopenharmony_ci- **Solution**
41e41f4b71Sopenharmony_ci  
42e41f4b71Sopenharmony_ci  Run the following command to install Python. The following uses Python 3.8 as an example.
43e41f4b71Sopenharmony_ci
44e41f4b71Sopenharmony_ci  
45e41f4b71Sopenharmony_ci  ```
46e41f4b71Sopenharmony_ci  sudo apt-get install python3.8
47e41f4b71Sopenharmony_ci  ```
48e41f4b71Sopenharmony_ci
49e41f4b71Sopenharmony_ci- **Possible Cause 2**
50e41f4b71Sopenharmony_ci  
51e41f4b71Sopenharmony_ci  The soft link to Python does not exist in the **usr/bin** directory.
52e41f4b71Sopenharmony_ci
53e41f4b71Sopenharmony_ci  ![faq-python-error](figures/faq-python-error.png)
54e41f4b71Sopenharmony_ci
55e41f4b71Sopenharmony_ci- **Solution**
56e41f4b71Sopenharmony_ci  
57e41f4b71Sopenharmony_ci  Run the following commands to add the soft link to Python:
58e41f4b71Sopenharmony_ci
59e41f4b71Sopenharmony_ci  
60e41f4b71Sopenharmony_ci  ```
61e41f4b71Sopenharmony_ci  # cd /usr/bin/ 
62e41f4b71Sopenharmony_ci  # which python3
63e41f4b71Sopenharmony_ci  # ln -s /usr/local/bin/python3 python
64e41f4b71Sopenharmony_ci  # python --version
65e41f4b71Sopenharmony_ci  ```
66e41f4b71Sopenharmony_ci
67e41f4b71Sopenharmony_ci  Example:
68e41f4b71Sopenharmony_ci
69e41f4b71Sopenharmony_ci  ![faq-python-add-soft-link](figures/faq-python-add-soft-link.png)
70e41f4b71Sopenharmony_ci
71e41f4b71Sopenharmony_ci
72e41f4b71Sopenharmony_ci## The message indicating Python 3 cannot be found is displayed during the build process
73e41f4b71Sopenharmony_ci
74e41f4b71Sopenharmony_ci- **Symptom**
75e41f4b71Sopenharmony_ci  
76e41f4b71Sopenharmony_ci  ![faq-python3-not-found](figures/faq-python3-not-found.png)
77e41f4b71Sopenharmony_ci
78e41f4b71Sopenharmony_ci- **Possible Causes**
79e41f4b71Sopenharmony_ci
80e41f4b71Sopenharmony_ci  Python 3 is not installed.
81e41f4b71Sopenharmony_ci
82e41f4b71Sopenharmony_ci- **Solution**
83e41f4b71Sopenharmony_ci  
84e41f4b71Sopenharmony_ci  Run the following command to install Python 3:
85e41f4b71Sopenharmony_ci
86e41f4b71Sopenharmony_ci  
87e41f4b71Sopenharmony_ci  ```
88e41f4b71Sopenharmony_ci  sudo apt-get install python3.8
89e41f4b71Sopenharmony_ci  ```
90e41f4b71Sopenharmony_ci
91e41f4b71Sopenharmony_ci
92e41f4b71Sopenharmony_ci## "configure: error: no acceptable C compiler found in $PATH" is displayed during Python 3 installation
93e41f4b71Sopenharmony_ci
94e41f4b71Sopenharmony_ci- **Symptom**
95e41f4b71Sopenharmony_ci  
96e41f4b71Sopenharmony_ci  The following information is displayed during the Python 3 installation process:
97e41f4b71Sopenharmony_ci
98e41f4b71Sopenharmony_ci  
99e41f4b71Sopenharmony_ci  ```
100e41f4b71Sopenharmony_ci  configure: error: no acceptable C compiler found in $PATH. See 'config.log' for more details
101e41f4b71Sopenharmony_ci  ```
102e41f4b71Sopenharmony_ci
103e41f4b71Sopenharmony_ci- **Possible Causes**
104e41f4b71Sopenharmony_ci  
105e41f4b71Sopenharmony_ci  GCC is not installed.
106e41f4b71Sopenharmony_ci
107e41f4b71Sopenharmony_ci- **Solution**
108e41f4b71Sopenharmony_ci  1. Run the **apt-get install gcc** command to install **gcc** online.
109e41f4b71Sopenharmony_ci  2. Install Python 3.
110e41f4b71Sopenharmony_ci
111e41f4b71Sopenharmony_ci
112e41f4b71Sopenharmony_ci## "-bash: make: command not found" is displayed during Python 3 installation
113e41f4b71Sopenharmony_ci
114e41f4b71Sopenharmony_ci- **Symptom**
115e41f4b71Sopenharmony_ci  
116e41f4b71Sopenharmony_ci  The following information is displayed during the Python 3 installation process:
117e41f4b71Sopenharmony_ci
118e41f4b71Sopenharmony_ci  
119e41f4b71Sopenharmony_ci  ```
120e41f4b71Sopenharmony_ci  -bash: make: command not found
121e41f4b71Sopenharmony_ci  ```
122e41f4b71Sopenharmony_ci
123e41f4b71Sopenharmony_ci- **Possible Causes**
124e41f4b71Sopenharmony_ci  
125e41f4b71Sopenharmony_ci  make is not installed.
126e41f4b71Sopenharmony_ci
127e41f4b71Sopenharmony_ci- **Solution**
128e41f4b71Sopenharmony_ci  1. Run the **apt-get install make** command to install make online.
129e41f4b71Sopenharmony_ci  2. Install Python 3.
130e41f4b71Sopenharmony_ci
131e41f4b71Sopenharmony_ci
132e41f4b71Sopenharmony_ci## "No module named '_ctypes'" is displayed during Python 3 installation
133e41f4b71Sopenharmony_ci
134e41f4b71Sopenharmony_ci- **Symptom**
135e41f4b71Sopenharmony_ci  
136e41f4b71Sopenharmony_ci  The following information is displayed during the Python 3 installation process:
137e41f4b71Sopenharmony_ci
138e41f4b71Sopenharmony_ci  
139e41f4b71Sopenharmony_ci  ```
140e41f4b71Sopenharmony_ci  ModuleNotFoundError: No module named '_ctypes'
141e41f4b71Sopenharmony_ci  ```
142e41f4b71Sopenharmony_ci
143e41f4b71Sopenharmony_ci- **Possible Causes**
144e41f4b71Sopenharmony_ci  
145e41f4b71Sopenharmony_ci  libffi and libffi-devel are not installed.
146e41f4b71Sopenharmony_ci
147e41f4b71Sopenharmony_ci- **Solution**
148e41f4b71Sopenharmony_ci  1. Run the **apt-get install libffi* -y** command to install libffi and libffi-devel online.
149e41f4b71Sopenharmony_ci  2. Install Python 3.
150e41f4b71Sopenharmony_ci
151e41f4b71Sopenharmony_ci
152e41f4b71Sopenharmony_ci## "No module named 'Crypto'" is displayed during the build process
153e41f4b71Sopenharmony_ci
154e41f4b71Sopenharmony_ci- **Symptom**
155e41f4b71Sopenharmony_ci  
156e41f4b71Sopenharmony_ci  The following information is displayed during the build process:
157e41f4b71Sopenharmony_ci
158e41f4b71Sopenharmony_ci  
159e41f4b71Sopenharmony_ci  ```
160e41f4b71Sopenharmony_ci  ModuleNotFoundError: No module named 'Crypto'
161e41f4b71Sopenharmony_ci  ```
162e41f4b71Sopenharmony_ci
163e41f4b71Sopenharmony_ci- **Possible Causes**
164e41f4b71Sopenharmony_ci  
165e41f4b71Sopenharmony_ci  **Crypto** is not installed.
166e41f4b71Sopenharmony_ci
167e41f4b71Sopenharmony_ci- **Solution**
168e41f4b71Sopenharmony_ci  Method 1: Run the **pip3 install Crypto** command to install **Crypto** online.
169e41f4b71Sopenharmony_ci
170e41f4b71Sopenharmony_ci  Method 2: Install **Crypto** offline.
171e41f4b71Sopenharmony_ci
172e41f4b71Sopenharmony_ci  Download the source code from [PyPI](https://pypi.org/project/pycrypto/#files).
173e41f4b71Sopenharmony_ci
174e41f4b71Sopenharmony_ci  ![faq-download-pycrypto](figures/faq-download-pycrypto.png)
175e41f4b71Sopenharmony_ci
176e41f4b71Sopenharmony_ci  Save the source package to the Linux server, decompress the package, and run the **python3 setup.py install** command to install **Crypto**.
177e41f4b71Sopenharmony_ci
178e41f4b71Sopenharmony_ci  Start the build again.
179e41f4b71Sopenharmony_ci
180e41f4b71Sopenharmony_ci
181e41f4b71Sopenharmony_ci## (Hi3861) "No module named 'ecdsa'" is displayed during the build process
182e41f4b71Sopenharmony_ci
183e41f4b71Sopenharmony_ci- **Symptom**
184e41f4b71Sopenharmony_ci  
185e41f4b71Sopenharmony_ci  The following information is displayed during the build process:
186e41f4b71Sopenharmony_ci
187e41f4b71Sopenharmony_ci  
188e41f4b71Sopenharmony_ci  ```
189e41f4b71Sopenharmony_ci  ModuleNotFoundError: No module named 'ecdsa'
190e41f4b71Sopenharmony_ci  ```
191e41f4b71Sopenharmony_ci
192e41f4b71Sopenharmony_ci- **Possible Causes**
193e41f4b71Sopenharmony_ci  
194e41f4b71Sopenharmony_ci  **ecdsa** is not installed.
195e41f4b71Sopenharmony_ci
196e41f4b71Sopenharmony_ci- **Solution**
197e41f4b71Sopenharmony_ci  Method 1: Run the **pip3 install ecdsa** command to install **ecdsa** online.
198e41f4b71Sopenharmony_ci
199e41f4b71Sopenharmony_ci  Method 2: Offline installation
200e41f4b71Sopenharmony_ci
201e41f4b71Sopenharmony_ci  Download the installation package from [PyPI](https://pypi.org/project/ecdsa/#files).
202e41f4b71Sopenharmony_ci
203e41f4b71Sopenharmony_ci  ![faq-download-ecdsa](figures/faq-download-ecdsa.png)
204e41f4b71Sopenharmony_ci
205e41f4b71Sopenharmony_ci  Save the installation package to the Linux server and run the **pip3 install ecdsa-0.15-py2.py3-none-any.whl** command to install ecdsa.
206e41f4b71Sopenharmony_ci
207e41f4b71Sopenharmony_ci  Start the build again.
208e41f4b71Sopenharmony_ci
209e41f4b71Sopenharmony_ci
210e41f4b71Sopenharmony_ci## (Hi3861)" Could not find a version that satisfies the requirement six>=1.9.0" is displayed during the build process
211e41f4b71Sopenharmony_ci
212e41f4b71Sopenharmony_ci- **Symptom**
213e41f4b71Sopenharmony_ci  
214e41f4b71Sopenharmony_ci  The following information is displayed during the build process:
215e41f4b71Sopenharmony_ci
216e41f4b71Sopenharmony_ci  
217e41f4b71Sopenharmony_ci  ```
218e41f4b71Sopenharmony_ci  Could not find a version that satisfies the requirement six>=1.9.0
219e41f4b71Sopenharmony_ci  ```
220e41f4b71Sopenharmony_ci
221e41f4b71Sopenharmony_ci- **Possible Causes**
222e41f4b71Sopenharmony_ci  
223e41f4b71Sopenharmony_ci  **six** is not installed.
224e41f4b71Sopenharmony_ci
225e41f4b71Sopenharmony_ci- **Solution**
226e41f4b71Sopenharmony_ci  Method 1: Run the **pip3 install six** command to install **six** online.
227e41f4b71Sopenharmony_ci
228e41f4b71Sopenharmony_ci  Method 2: Install **six** offline.
229e41f4b71Sopenharmony_ci
230e41f4b71Sopenharmony_ci  Download the installation package from [PyPI](https://pypi.org/project/six/#files).
231e41f4b71Sopenharmony_ci
232e41f4b71Sopenharmony_ci  ![faq-download-six](figures/faq-download-six.png)
233e41f4b71Sopenharmony_ci
234e41f4b71Sopenharmony_ci  Save the source code to the Linux server and run the **pip3 install six-1.14.0-py2.py3-none-any.whl** command to install **six**.
235e41f4b71Sopenharmony_ci
236e41f4b71Sopenharmony_ci  Start the build again.
237e41f4b71Sopenharmony_ci
238e41f4b71Sopenharmony_ci
239e41f4b71Sopenharmony_ci## (Hi3861) "cannot find -lgcc" is displayed during the build process
240e41f4b71Sopenharmony_ci
241e41f4b71Sopenharmony_ci- **Symptom**
242e41f4b71Sopenharmony_ci  
243e41f4b71Sopenharmony_ci  The following information is displayed during the build process:
244e41f4b71Sopenharmony_ci
245e41f4b71Sopenharmony_ci  
246e41f4b71Sopenharmony_ci  ```
247e41f4b71Sopenharmony_ci  riscv32-unknown-elf-ld: cannot find -lgcc
248e41f4b71Sopenharmony_ci  ```
249e41f4b71Sopenharmony_ci
250e41f4b71Sopenharmony_ci- **Possible Causes**
251e41f4b71Sopenharmony_ci  
252e41f4b71Sopenharmony_ci  The gcc_riscv32 path is incorrectly set as follows. There is an extra slash (/) after **bin**.
253e41f4b71Sopenharmony_ci
254e41f4b71Sopenharmony_ci  
255e41f4b71Sopenharmony_ci  ```
256e41f4b71Sopenharmony_ci  ~/gcc_riscv32/bin/:/data/toolchain/
257e41f4b71Sopenharmony_ci  ```
258e41f4b71Sopenharmony_ci
259e41f4b71Sopenharmony_ci- **Solution**
260e41f4b71Sopenharmony_ci  
261e41f4b71Sopenharmony_ci  Modify the gcc_riscv32 path as follows:
262e41f4b71Sopenharmony_ci
263e41f4b71Sopenharmony_ci  
264e41f4b71Sopenharmony_ci  ```
265e41f4b71Sopenharmony_ci  ~/gcc_riscv32/bin:/data/toolchain/
266e41f4b71Sopenharmony_ci  ```
267e41f4b71Sopenharmony_ci
268e41f4b71Sopenharmony_ci
269e41f4b71Sopenharmony_ci## (Hi3861) An lsb_release error occurs during kconfiglib installation
270e41f4b71Sopenharmony_ci
271e41f4b71Sopenharmony_ci- **Symptom**
272e41f4b71Sopenharmony_ci  
273e41f4b71Sopenharmony_ci  The following information is displayed during the **kconfiglib** installation process:
274e41f4b71Sopenharmony_ci
275e41f4b71Sopenharmony_ci  
276e41f4b71Sopenharmony_ci  ```
277e41f4b71Sopenharmony_ci  subprocess.CalledProcessError: Command '('lsb_release', '-a')' returned non-zero exit status 1.
278e41f4b71Sopenharmony_ci  ```
279e41f4b71Sopenharmony_ci
280e41f4b71Sopenharmony_ci- **Possible Causes**
281e41f4b71Sopenharmony_ci  
282e41f4b71Sopenharmony_ci  The Python version matched with the **lsb_release** module is different from the current Python version.
283e41f4b71Sopenharmony_ci
284e41f4b71Sopenharmony_ci- **Solution**
285e41f4b71Sopenharmony_ci  
286e41f4b71Sopenharmony_ci  Run the **find / -name lsb_release** command, for example, **sudo rm -rf /usr/bin/lsb_release** to locate and delete **lsb_release**.
287