SomeCubingNerd
SomeCubingNerd

Reputation: 25

When running gym, sanity check returns attribute error for numpy __version__

I am trying to get open AI gym working, but i am facing a very persistent error.
When I run my programme (just the simple demo cartpole solver) I get this error. (The file "gperm.py" is the cartpole solver)

File "gperm.py", line 1, in <module>
import gym
File "/Users/sonyaferraro/Desktop/dpy/gym/__init__.py", line 48, in <module>
sanity_check_dependencies()
File "/Users/sonyaferraro/Desktop/dpy/gym/__init__.py", line 20, in sanity_check_dependencies
if distutils.version.LooseVersion(numpy.__version__) < distutils.version.LooseVersion('1.10.4'):

and finally prints:

AttributeError: module 'numpy' has no attribute '__version__'

This is strange because I did a full pip install of numpy and even tried to git clone it neither worked. I have checked to make sure I have no other files called numpy and everything seems to be in check.

If anyone else is having this same problem or anyone has a solution it would be greatly appreciated.

It also prints a "hint" prompting me to try: pip install -U numpy.

    logger.warn("You have 'numpy' version %s installed, but 'gym' requires at least 1.10.4. HINT: upgrade via 'pip install -U numpy'.", numpy.__version__)

I do have a version of numpy>= 1.10.4 though so that shouldn't be popping up right?(cant remember exactly what version)

Using the pip install -U numpy however returns an 'SNIMissingWarning', an 'InsequrePlatformWarning' and the following:

The directory '/Users/sonyaferraro/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/Users/sonyaferraro/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.

I honestly have no idea what that is telling me to do as I do have permission for those directories.

Upvotes: 2

Views: 151

Answers (1)

mdegis
mdegis

Reputation: 2438

Based on your terminal output, I think you're using MacOS with brew.

brew link --overwrite numpy seems to have fixed the issue for me.

Upvotes: 2

Related Questions