ImportError: No module named when module is there

后端 未结 4 655
名媛妹妹
名媛妹妹 2021-01-15 01:52

I usually run python2 but I am playing with python3. Right now I am confused as to why I am getting this error.

When I run the command ./test_web_events.py

4条回答
  •  爱一瞬间的悲伤
    2021-01-15 02:18

    This is most likely because you haven't added /python_lib/qe to your PYTHONPATH.

    When you try to import a module, the interpreter will look for it only in a certain number of places, you cannot arbitrarily try to import a module from anywhere.

    The most common ways are to have a package installed via pip, to have the module sitting in the same directory as the .py file, or to have added the path to that module to the PYTHONPATH.

    See: https://docs.python.org/2/tutorial/modules.html#the-module-search-path

    It seems like the latter case is most likely what you want to do. This is going to be dependent on your OS, but googling it should be straightforward.

提交回复
热议问题