-3

I have downloaded Python 3.6 Portable.

I need to use numpy.

I have downloaded it using git: git clone https://github.com/numpy/numpy.git numpy . Copied the directory "numpy" to the Python directory.

Now, when I use "import numpy", I get the following error:

ImportError: Error importing numpy: you should not try to import numpy from its source directory; please exit the numpy source tree, and relaunch your python interpreter from there.

What should I do?

And no, it's not a duplicate of Explain why numpy should not be imported from source directory, since copying the numpy to the directory "site-packages" in the Python directory makes it so, that the interpreter simply does not see the numpy module.

The suggestion that this is the duplicate of a question where author asks to EXPLAIN something, is not accurate. Since I didn't ask for explanation, I asked, how can I make this WORK. And the "possible duplicate" question only tells about he way is DOES NOT WORK.

By the way, I have already found the way to get what I want without numpy. But numpy is the solution, what was advised in other stackovervlow answer, and this becomes time consuming for those, who uses portable Python, since there seems to be no obvious solution for them. And they are not told that when advised to use numpy.

The answers

Jaroslav Tavgen
  • 312
  • 1
  • 9
  • The answer to the question you linked is still relevant, though. Cloning the numpy source repo doesn't build all the C extensions. – Dominik Stańczak Nov 12 '17 at 13:38
  • just because you cloned the repo and have the source code doesn't mean the underlying C extensions for which the library relies on were built – Jason Nov 12 '17 at 14:07
  • Possible duplicate of [Explain why numpy should not be imported from source directory](https://stackoverflow.com/questions/14570011/explain-why-numpy-should-not-be-imported-from-source-directory) – phd Nov 12 '17 at 14:47
  • It is not. I did not ask to explain, I asked, how to make it work. – Jaroslav Tavgen Nov 15 '17 at 12:54

1 Answers1

3

NumPy is not just a set of Python files. It also contains a set of C extensions that need to be compiled to be used. Thus you can't just copy the files into your path and expect it to work.

For instructions on installing NumPy, see this page: https://docs.scipy.org/doc/numpy-1.13.0/user/install.html

jakevdp
  • 77,104
  • 11
  • 125
  • 160