ImportError: No module named ***** in python

前端 未结 1 925
南笙
南笙 2020-12-17 14:44

I am very new to python, about one month, and am trying to figure out how the importing works in python. I was told that I can import any \'module\' that has Python code in

相关标签:
1条回答
  • 2020-12-17 15:03

    These files are not on sys.path. It should have been though.

    If you want to access them from the interpreter, you will need to add the location to sys.path

    >>> import sys
    >>> print sys.path
    >>> sys.path.append('C:\\Users\\Cube\\Documents\\Python')
    >>> import reduc
    

    You could also include the path in environment variable - PYTHONPATH

    See the details on module search path here :

    • http://docs.python.org/tutorial/modules.html#the-module-search-path
    • http://docs.python.org/library/sys.html#sys.path

    Also look at (PYTHONPATH) environment variable details here:

    • http://docs.python.org/using/cmdline.html#environment-variables
    0 讨论(0)
提交回复
热议问题