Python has installed a package, but the module in the import package is wrong without this package

Source: Internet
Author: User

Perform a view of the import sys; print(sys.path) Python search path and make sure your module is in the Python search path

search paths and packages for Python (package)

Python's search path is actually a list, it is the guide into the module, Python will automatically find the path to search this list, if the path exists to import the module file is imported successfully, otherwise the import failed:

>>>ImportSYS>>>sys.path["','C:\\python33\\lib\\idlelib','C:\\windows\\system32\\python33.zip','C:\\python33\\dlls','C:\\python33\\lib','c:\\python33','c:\\python33\\lib\\site-packages']>>> Sys.path.append ('E:\\python')>>>sys.path["','C:\\python33\\lib\\idlelib','C:\\windows\\system32\\python33.zip','C:\\python33\\dlls','C:\\python33\\lib','c:\\python33','c:\\python33\\lib\\site-packages','E:\\python']>>>

When installing third-party modules, if they are not installed in a standard manner, in order to be able to reference (import) These modules, the installation path of these modules must be added to Sys.path, in the following ways:

The simplest way to do this is to add a path profile under a directory in Sys.path, most commonly in the .../site-package/directory. The path profile extension is ". PTH", where each row contains a separate path that is added to the Sys.path list (verified). The path in ". PTH" can be either an absolute or a relative path, relative to the path that contains the ". PTH" file.

The ultimate solution: Reinstall Python

Python has installed a package, but the module in the import package is wrong without this package

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.