Explain why numpy should not be imported from source directory

前端 未结 1 725
离开以前
离开以前 2020-12-05 20:12

Disclaimer of research:

I have examined the following other StackOverflow questions:

  • How to import numpy in python shell

  • How can I

1条回答
  •  有刺的猬
    2020-12-05 20:40

    numpy includes extension modules written in C. You will need to build these extension modules before the numpy package is complete. The most robust way to do this is to build it and install it to site-packages like normal. You can also install it to another directory using the standard distutils options for this. However, once you have installed it, you should change your directory out of the source tree. Python starts looking for packages in your current directory, so the presence of the incomplete numpy package (without the necessary built C extension modules) will be picked up first and lead to the error that message that you quote. This happens a lot, so we give a long message explaining what to do.

    0 讨论(0)
提交回复
热议问题