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

PySerial 3.4无法在Python3.5+导入求助:Python2.7正常但3.6.4报模块未找到

Troubleshooting PySerial 3.4 "Module Not Found" Error in Python 3.5+

Hey there, let's work through this frustrating PySerial import issue together. It's so confusing when a package documented to support your Python version throws a "module not found" error—especially since it runs smoothly in Python 2.7. Here are the most reliable fixes to try:

  • Double-check your Python environment alignment
    It’s super easy to accidentally install packages for a different Python version without noticing. Run these commands to confirm everything lines up:

    • List installed packages for your Python 3.6.4 instance: python3.6 -m pip list | grep pyserial
    • Verify your pip and Python paths match: run which python3.6 and which pip3.6—they should point to the same environment directory. If not, use the full path to pip or stick with the python3.6 -m pip syntax to install packages.
  • Reinstall PySerial explicitly for Python 3
    Skip using plain pip install (which might default to Python 2) and use the Python-specific pip command to install the exact 3.4 version:

    python3.6 -m pip install pyserial==3.4
    

    If you hit permission issues, add the --user flag to install it in your user directory instead of system-wide:

    python3.6 -m pip install --user pyserial==3.4
    
  • Confirm you’re using the correct import statement
    A super common gotcha: in Python 3, PySerial is imported as import serial, not import pyserial. If you’re using the latter, that’s definitely the root of your error! Test the import with this quick command:

    python3.6 -c "import serial; print(f'PySerial version: {serial.__version__}')"
    
  • Check for virtual environment conflicts
    If you’re using a virtual environment, make sure you’ve activated it before installing PySerial. If you installed the package outside the venv, your active environment won’t be able to find it. Activate your venv first, then rerun the install command.

  • Verify the installation location
    Run this command to see where PySerial is installed, and confirm the path is in your Python 3.6.4’s sys.path:

    python3.6 -c "import serial; print(serial.__file__)"
    

    If the path doesn’t match your Python 3.6 site-packages directory, uninstall it from the wrong environment and reinstall to the correct one.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.20 11:46:14