Forum Archive

import numpy fails

Dan_Patterson

worked yesterday (day 2 using Pythonista)... getting an error ... ImportError: cannot import name add_newdocs
The general configuration doesn't allow to check site packages like on a windows machine (I am lost without a directory browser...noob on iPad)

Any help would be appreciated to ensure that numpy and matplotlib are functional...the reason I bought this program in the first place

ccc

The code at http://omz-forums.appspot.com/pythonista/post/6055977640001536 should show that numpy is working.

The code at http://omz-forums.appspot.com/pythonista/post/5868619489607680 should show that matplotlib is working.

It is unclear why you are trying to import add_newdocs but perhaps if you could post some code we could get a better understanding.

Dan_Patterson

I wasn't try to import add_newdocs, I tried

import numpy as np

and it failed

ccc

Does the code at http://omz-forums.appspot.com/pythonista/post/6055977640001536 work in your version of Pythonista?

Dan_Patterson

I don't know what was wrong but the problem seems to have self-rectified without any intervention on my part Thanks for providing responses

geomith

Just installed pythonista and tried to run the polar plot demo. Am getting "name 'random_sample' is not defined" on "import numpy as np". Error occurs in init.py module line 103.

Any suggestions?

Pythonista looks like a great system, and the examples that don't reference numpy are working - but I'd really like to use numpy.

zipit

Sound mysterious, I am using both using numpy and matlotlib quite regularly. The only things I can say are:
* The polar plot example runs fine for me in both Python enviroments.
* ~~What you told us about the exception is a bit confusing since neither numpy nor matplotlib have an init.py file afaik (they have both multiple __init__.py files though)~~ edit: I just realized that you were probably only struggling with the forums markdown interface since your init.py is printed bold (you have to escape the first two underscores: \_\_init__.py).
* The polar plot example does not import anything from numpy.random and neither does matplotlib.pyplot.

I cannot think of anything obvious, I think you will have to describe more precisely (actually copy and paste the full trace of the exception) what you are doing and what is going wrong.

JonB

Try force quitting pythonista. Since numpy is a big module, if you ever cancel a script while numpy or matplotlib are in the middle of importing, it is hard to recover

geomith

Force quit solved the problem. Thanks to both responders for helping a newbie.