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

安装NVIDIA及CUDA驱动后Python3.5报_tkinter模块缺失错误

Hey Jonny, let's work through this _tkinter error you're hitting with Python 3.5 after setting up NVIDIA and CUDA drivers. Since you noted python3-tk is already up-to-date and Python 3.6 is installed alongside, the issue is likely tied to Python 3.5's tkinter association or environment interference from CUDA. Here are actionable steps to fix this:

Fixes for "No module named '_tkinter'" in Python 3.5
  • First, confirm your Python 3.5 installation's tkinter status
    Run these commands to narrow down if the problem is specific to your Python 3.5 build:

    # Get the full path of your Python 3.5 executable
    which python3.5
    # Test if tkinter loads with this Python version
    python3.5 -c "import tkinter; print(tkinter.__file__)"
    

    If this throws the same error, your Python 3.5's tkinter module is either missing or broken—note that the default python3-tk package is often linked to your system's primary Python version (which is 3.6 in your case).

  • Install Python 3.5-specific tkinter package
    On Ubuntu/Debian systems, version-specific tkinter packages exist for alternative Python releases. Try installing the one for Python 3.5:

    sudo apt-get install python3.5-tk
    

    If you get a "package not found" error, add the deadsnakes PPA (which maintains older Python versions) first:

    sudo add-apt-repository ppa:deadsnakes/ppa
    sudo apt-get update
    sudo apt-get install python3.5-tk
    
  • Check if CUDA's environment variables are breaking dependencies
    CUDA installation often modifies LD_LIBRARY_PATH, which can override system libraries that tkinter relies on. Test this by temporarily unsetting the variable:

    unset LD_LIBRARY_PATH && python3.5 -c "import tkinter"
    

    If this works, adjust your environment to prioritize system libraries. Edit your ~/.bashrc or ~/.profile file and add this line (ensuring system paths come first):

    export LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu/:$LD_LIBRARY_PATH
    

    Reload your profile with source ~/.bashrc to apply the change.

  • Reinstall Python 3.5 and its tkinter module
    If corruption is the issue, reinstall Python 3.5 to fix broken files:

    sudo apt-get reinstall python3.5 python3.5-tk
    

    If you compiled Python 3.5 from source originally, recompile it with tkinter support. First install required dependencies:

    sudo apt-get install tk-dev tcl-dev
    

    Then re-run the configure step with tk/tcl flags before compiling:

    ./configure --with-tk --with-tcl
    make && sudo make install
    
  • Verify virtual environment settings
    If you're using a virtual environment for Python 3.5, it might be isolated from system-wide tkinter. Create a new environment with system site-packages enabled to test:

    python3.5 -m venv --system-site-packages my_fixed_env
    source my_fixed_env/bin/activate
    python -c "import tkinter"
    

    If this works, you can either switch to this environment or copy the tkinter files from your system Python 3.5's site-packages to your existing virtual environment.

内容的提问来源于stack exchange,提问作者Jonny

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.27 03:39:38