You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

已安装pyuic4仍提示bash: pyuic4: command not found的问题求助

Fixing "bash: pyuic4: command not found" on CentOS 7

Hey there, let's troubleshoot this frustrating issue step by step—even though you've got Qt4, Qt Designer, and pyuic4 installed, the shell can't locate the command. Here's what to do:

  • First, track down where pyuic4 is actually installed
    The shell doesn't know where the executable lives, so let's hunt it down. Run this command to search your entire system (we'll suppress irrelevant error messages to keep things clean):

    find / -name pyuic4 2>/dev/null
    

    You might get results like /usr/bin/pyuic4, /usr/local/bin/pyuic4, or even a Python script path like /usr/lib64/python2.7/site-packages/PyQt4/uic/pyuic.py.

  • Check if the directory is in your system's PATH
    Next, verify if the folder containing pyuic4 is listed in your executable path. Run:

    echo $PATH
    

    If the path from the previous step isn't here, that's exactly why the shell can't find pyuic4.

  • Temporarily add the path to your current session
    To test things out quickly, add the directory to your PATH for the current terminal session. Replace /path/to/pyuic4/folder with the actual directory you found:

    export PATH=$PATH:/path/to/pyuic4/folder
    

    Now try running pyuic4 -x demo.ui -o demo.py again—it should work right away.

  • Make the path change permanent
    To avoid repeating this every time you open a terminal, add the export line to your bash profile. Edit ~/.bashrc with your favorite editor (like nano or vim):

    nano ~/.bashrc
    

    Add this line at the end (replace the path with your actual one):

    export PATH=$PATH:/path/to/pyuic4/folder
    

    Save the file, then reload the profile to apply changes immediately:

    source ~/.bashrc
    
  • Alternative: Call the script directly with Python
    If you found pyuic4 as a Python script (like pyuic.py), you can run it directly using Python 2 (since PyQt4 on CentOS 7 is tied to Python 2):

    python /usr/lib64/python2.7/site-packages/PyQt4/uic/pyuic.py -x demo.ui -o demo.py
    
  • Last resort: Create a symbolic link
    If the above steps don't work, you can create a soft link from the pyuic4 executable to a directory that's already in your PATH (like /usr/bin). For example:

    sudo ln -s /path/to/actual/pyuic4 /usr/bin/pyuic4
    

    This tells the system exactly where to find the command whenever you type pyuic4.

Quick heads up: CentOS 7 uses Python 2 as the default, so make sure you're not accidentally using a Python 3 environment—PyQt4 only works with Python 2, which could also cause path-related weirdness.

内容的提问来源于stack exchange,提问作者Guna Sekaran J

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 03:26:52