Solve Geany editor can not import package problem matplotlib

Recently read "Python programming from entry to practice" This book, seeing Chapter 15, data is generated, encountered a problem: matplotlib always displayed in the module can not find matplotlib Geany editor. After viewing some information on the Internet to find out why.

problem causes

You can do a test to look at the character does not meet what I say:

  • Reinstall matplotlib in the terminal, this time you will be prompted to already be installed:

    But you will find the path to the installation prompts:

    namely: in / home / username /anaconda3/lib/python3.6/site-packages under
  • View Geany editor to find the path to the module
    code is as follows:
import sys
print(sys.path)

At this point you will find that when Geany to find the original package, and not to take the next anaconda3 directory to find. This time we will find out the cause of the problem. In fact, we installed two python interpreter, one is ubuntu system comes, and the other is through our anaconda installation. When we use Geany editor actually use the system comes with python interpreter, it looks for the packet path is to take the path down to find the interpreter association. Associated path default is not included in the module mounting anaconda3 directory. Therefore, we need to be resolved manually.

Of course, if you have not installed Python using anaconda on these issues will not occur.

solution

  • Scheme One: the simplest method
    used for each of the matplotlib Geany program editor add the following code:
import sys
sys.path.append('/home/用户名/anaconda3/lib/python3.6/site-packages')

Namely: Each package path manually add it, but the drawback is that each addition is only valid in this program, not permanently solve the problem.

  • Option Two: modify environment variables
    This method can certainly solve the problem, but it is recommended not to modify environment variables, mistaken a lot of trouble.

  • Scheme III: Add the python in a default installation file path, as follows:
    (1) cut to the terminal: /usr/local/lib/python3.6/dist-packagesthe directory
    (2) .pth create a file extension, a file path written matplotlib installation:/home/yuanjianyu/anaconda3/lib/python3.6/site-packages

Guess you like

Origin www.cnblogs.com/lasnitch/p/11718591.html