---
# System prepended metadata

title: 疑難雜症解決區

---

# 疑難雜症解決區

## miniconda
1. 前往[安裝頁面](https://docs.conda.io/projects/miniconda/en/latest/)
2. 重開terminal
3. `conda --version` 確認安裝是否成功
- How to create conda env?
    ```
        conda create --name {env_name} python={version}
    ```
- Check conda list
    ```
        conda env list
    ```
- Activate conda
    ```
        conda activate {env_name}
    ```
- Select interpreter
    - choose through path: `/home/usr/miniconda3/envs/{env_name}/bin/python`
- Delete conda
    ```
        conda env remove --name {env_name}
    ```
### For windows download scripts
```
powershell -ExecutionPolicy Bypass

# Change condaexe and condadir to the wanted paths
# In the following it downloads and installs miniconda in C:\Users\your_user
$condaurl = "https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe"
# Path where miniconda installer will be downloaded
$condaexe = "${env:userprofile}\Miniconda3-latest-Windows-x86_64.exe"
# Path where miniconda will be installed 
$condadir = "${$env:userprofile}\miniconda3"

echo "Installing Miniconda in: $condadir"
# Download miniconda installer
curl.exe -C - $condaurl -o $condaexe
# Install miniconda
Start-Process $condaexe -Args "/InstallationType=JustMe /RegisterPython=0 /S /D=$condadir" -wait
# Add condabin to path to have `conda` command available
$env:PATH = "$condadir\condabin;" + $env:PATH
# Initialize conda: it creates the powershell profile script
conda init powershell
# Load the profile for current session: it activates (base) environment
invoke-expression -Command "$env:userprofile\Documents\WindowsPowerShell\profile.ps1"
# Create new environment
conda create -y -n test python=3.7
# activate the newly created environment
conda activate test
# check that it is really activated: the star should be on test environment
conda env list
```
- 以管理員身分開啟PS，輸入以下:
    - Set-ExecutionPolicy -ExecutionPolicy Bypass
- 如果沒有辦法以admin進入，則只能在每次要使用前輸入:
    - powershell -ExecutionPolicy Bypass

## PyQt5
1. 缺少 `libxcb-xinerama.so.0`
    - 可能會報以下錯誤
        ```!
        Cannot load library /home/pulsar/miniconda3/envs/cvdl-proj-1/lib/python3.8/site-packages/PyQt5/Qt5/plugins/platforms/libqxcb.so: (libxcb-xinerama.so.0: cannot open shared object file: No such file or directory)
        QLibraryPrivate::loadPlugin failed on "/home/pulsar/miniconda3/envs/cvdl-proj-1/lib/python3.8/site-packages/PyQt5/Qt5/plugins/platforms/libqxcb.so" : "Cannot load library /home/pulsar/miniconda3/envs/cvdl-proj-1/lib/python3.8/site-packages/PyQt5/Qt5/plugins/platforms/libqxcb.so: (libxcb-xinerama.so.0: cannot open shared object file: No such file or directory)"
        qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
        This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

        Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, webgl, xcb.

        [1]    180335 IOT instruction (core dumped)  python3 test.py
        ```
    - 解決方案
        - 先移動到出問題的目錄
            - `cd /home/pulsar/miniconda3/envs/cvdl-proj-1/lib/python3.8/site-packages/PyQt5/Qt5/plugins/platforms`
        - 檢查缺少什麼套件
            - `ldd libxcb.so`
        - 發現問題
            - 可以看到這行
                ```
                libxcb-xinerama.so.0 => not found
                ```
        - 安裝缺少的套件
            ```
            sudo apt update
            sudo apt install libxcb-xinerama.so.0
            ```
        - 檢查結果
            - `ldd libxcb.so`
            - 可以看到這行
                ```!
                libxcb-xinerama.so.0 => /lib/x86_64-linux-gnu/libxcb-xinerama.so.0 (0x00007faae595b000)
                ```
        - 結束！
2. 使用conda 創建環境 python=3.8 並啟用
3. pip install pyqt5
4. pip install opencv-contrib-python==3.4.8.29
## OpenCV SIFT
1. opencv-contrib-python 3.4.3以上的版本都不支援sift(因專利影響)
2. 可直接使用cv2.SIFT_create()，此要用此function就需要提高版本，造成前面幾題無法運作
3. 再降低版本到`python==3.7 opencv-contrib-python==3.4.2.16`
## tqdm.notebook in jupyter
- We have to degrade the version of these packages if we want to use tqdm.notebook under the jupyter (8.*.* version).
    ```!pip install --force-reinstall -v ipywidgets==7.7.2 jupyterlab_widgets==1.1.1```
## vllm
### 在同一個process中釋放model記憶體
https://github.com/vllm-project/vllm/issues/1908 (*尚未解決*)