Python can not find the package, 'Unresolved refrence', falling red wavy line, access to exclusive package folder problems

Looking package

1 issue

Abstract: install a good package, although can be used, but with a red wavy line under the package, there Unresolved refrence.

 Today encounter a problem, I downloaded a third-party installation package pyqt4 is exe format, did not find whl or compressed format, it is not in accordance with past Python setup.py install or -i pip install this package Download two ways.
 When using the exe file to install x64 pyqt4 this package would normally choose c: address / python27 be installed. However, when using a x32 exe file to install time, directly to the lib / sit-packages under arcgis installation files in the folder, so the control platform version, installed ridiculous .

 After a successful installation, at 2.73 on the platform, from PyQt4 import QtCore, QtGui time, will burst Unresolved refrence such a mistake will occur when using GtGui.QFileDialog 'unresolved, could not find a reference to' this The problem. In this way, 1. decline red wavy line appears. 2. Although normal operation, but the knock on the code, will not prompt function, error-prone.
 Reference pycharm Unresolved reference package can not be introduced in this article.
 This is because:
 for example, there are A, B, C three folders under item p, PyCharm p default project root directory for the source directory, will find each import from the root directory . So, we pyqt4 in the arcgis folder, p project in another place, so the problem will not find this package appears. However, you can still visit, because, python environment is created when the project exists, so will still be able to normal use. Just, pycharm default settings may not result in direct access to the.
Therefore, it is understood, pycharm although indirectly access python environment, but not direct, it will refrence unresolved .

2 Solutions

 1. pycharm the console consoles, set the root source added to pythonpath, the meaning is to set a good source root directory also serves as access path python package.
Here Insert Picture Description
 2. Open the file set, and then add the contents of the root directory
Here Insert Picture Description

After adding pyqt4 of the installation directory, meaning that there are two pycharm accessible source directory, and belong to the direct access .

 Before, I created a folder in the a.py A and b.py file, but in a situation where import b also can not find the package will be, but in accordance with the above settings are possible, the same principle.

Guess you like

Origin blog.csdn.net/qq_40260867/article/details/84105615