faqs-environment-setup.md 5.2 KB
Newer Older
W
wusongqing 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227
# 环境搭建常见问题<a name="ZH-CN_TOPIC_0000001215650793"></a>


## 轻量和小型系统<a name="section1742119306399"></a>

### 安装hb过程中,出现乱码、段错误<a name="section36351051193919"></a>

-   **现象描述**

    执行“python3 -m pip install --user ohos-build”出现乱码、段错误(segmentation fault)。


-   **可能原因**

    pip版本过低。

-   **解决办法**

    执行如下命令升级pip。

    ```
    python3 -m pip install -U pip
    ```


### 安装hb过程中,提示"cannot import 'sysconfig' from 'distutils'"<a name="section48221013144011"></a>

-   **现象描述**

    执行“python3 -m pip install --user ohos-build”提示"cannot import 'sysconfig' from 'distutils'"。


-   **可能原因**

    缺少distutils模块。

-   **解决办法**

    执行如下命令安装。

    ```
    sudo apt-get install python3.8-distutils
    ```


### 安装hb过程中,提示"module 'platform' has no attribute 'linux\_distribution'"<a name="section10307193044111"></a>

-   **现象描述**

    执行“python3 -m pip install --user ohos-build”提示"module 'platform' has no attribute 'linux\_distribution'"。


-   **可能原因**

    python3 pip安装兼容性问题。

-   **解决办法**

    执行如下命令重新安装pip。

    ```
    sudo apt remove python3-pip
    curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
    python get-pip.py
    ```


### 安装hb过程中,提示"Could not find a version that satisfies the requirement ohos-build"<a name="section8692735427"></a>

-   **现象描述**

    执行“python3 -m pip install --user ohos-build”提示"Could not find a version that satisfies the requirement ohos-build"


-   **可能原因**

    可能是网络环境较差导致的安装失败。

-   **解决办法**
    1.  请检查网络连接是否正常。如果网络有问题,请修复网络问题后重新安装。
    2.  若网络正常,请尝试指定临时pypi源的方式安装:

        ```
        python3 -m pip install -i https://pypi.tuna.tsinghua.edu.cn/simple ohos-build
        ```



### 安装python3过程中,提示“configure: error: no acceptable C compiler found in $PATH”<a name="section870082884217"></a>

-   **现象描述**

    安装python3过程中出现以下错误:

    ```
    configure: error: no acceptable C compiler found in $PATH. See 'config.log' for more details
    ```

-   **可能原因**

    环境中未安装“gcc”。

-   **解决办法**

    1、通过命令“apt-get install gcc”在线安装。

    2、完成后,重新安装python3。


### 安装python3过程中,提示“-bash: make: command not found”<a name="section198707170455"></a>

-   **现象描述**

    安装python3过程中出现以下错误:

    ```
    -bash: make: command not found
    ```

-   **可能原因**

    环境中未安装“make”。

-   **解决办法**

    1、通过命令“apt-get install make”在线安装。

    2、完成后,重新安装python3。


### 安装python3过程中,提示“zlib not available”<a name="section85401445204518"></a>

-   **现象描述**

    安装python3过程中出现以下错误:

    ```
    zipimport.ZipImportError: can't decompress data; zlib not available
    ```

-   **可能原因**

    环境中未安装“zlib”。

-   **解决办法**

    方法1:通过命令“apt-get install zlib”在线安装。

    方法2:如果软件源中没有该软件,请从“www.zlib.net”下载版本代码,并离线安装。

    ![](figures/download-zlib.png)

    完成下载后,通过以下命令安装:

    ```
    # tar xvf zlib-1.2.11.tar.gz
    # cd zlib-1.2.11
    # ./configure
    # make && make install
    ```

    完成后,重新安装python3。


### 安装python3过程中,提示“No module named '\_ctypes'”<a name="section12202694460"></a>

-   **现象描述**

    安装python3过程中出现以下错误:

    ```
    ModuleNotFoundError:No module named ‘_ctypes’
    ```


-   **可能原因**

    环境中未安装“libffi”和“libffi-devel”。


-   **解决办法**

    1、通过命令“apt-get install libffi\* -y”,在线安装。

    2、完成后,重新安装python3。


### 安装 kconfiglib时,遇到lsb\_release错误<a name="section5803174135115"></a>

-   **现象描述**

    安装kconfiglib过程中遇到如下错误打印:

    ```
    subprocess.CalledProcessError: Command '('lsb_release', '-a')' returned non-zero exit status 1.
    ```

-   **可能原因**

    lsb\_release模块基于的python版本与现有python版本不一致

-   **解决办法**

    执行"find / -name lsb\_release",找到lsb\_release位置并删除,如:"sudo rm -rf /usr/bin/lsb\_release"


### Linux编译服务器终端输入不识别的命令时提示“ImportError: No module named apt\_pkg”<a name="section510820516515"></a>

-   **现象描述**

    Linux编译服务器终端输入不识别的命令时,提示"ImportError: No module named apt\_pkg"


-   **可能原因**

    python3 apt安装兼容性问题。

-   **解决办法**

    执行如下命令重新安装python3-apt。

    ```
    sudo apt-get remove  python3-apt
    sudo apt-get install python3-apt
    ```