Python error “ImportError: No module named”

后端 未结 29 2694
野的像风
野的像风 2020-11-22 07:46

Python is installed in a local directory.

My directory tree looks like this:

(local directory)/site-packages/toolkit/interface.py

29条回答
  •  太阳男子
    2020-11-22 07:57

    In my case, because I'm using PyCharm and PyCharm create a 'venv' for every project in project folder, but it is only a mini env of python. Although you have installed the libraries you need in Python, but in your custom project 'venv', it is not available. This is the real reason of 'ImportError: No module named xxxxxx' occurred in PyCharm. To resolve this issue, you must add libraries to your project custom env by these steps:

    • In PyCharm, from menu 'File'->Settings
    • In Settings dialog, Project: XXXProject->Project Interpreter
    • Click "Add" button, it will show you 'Available Packages' dialog
    • Search your library, click 'Install Package'
    • Then, all you needed package will be installed in you project custom 'venv' folder.

    Enjoy.

提交回复
热议问题