-1

I have a code that might have been developed for Python 3, but my Centos is running Python 2.7:

def generateWeights(self, name_list):
    n = len(name_list)
    weights = np.flip(np.arange(1, n), axis=0)
    return weights / np.sum(weights)

I get for this part of the code:

AttributeError: 'module' object has no attribute 'flip'

Is there anything I should install/update, or an alternative code that will work?

Import part:

import requests
import urllib
import logging
import argparse
from lxml import objectify
import time
import pandas as pd
import numpy as np
import re
6
  • 1
    install python 3. sudo yum install python34u python34u-wheel Commented Dec 23, 2017 at 12:33
  • I can't. My webhost told me "Panel currently, does not support python3" Commented Dec 23, 2017 at 12:35
  • can you please give your full file code or at least import part. Commented Dec 23, 2017 at 12:35
  • or find some python 2.7 compatible version of numpy. Commented Dec 23, 2017 at 12:36
  • @UmarAsghar updated question Commented Dec 23, 2017 at 12:36

1 Answer 1

1

According to the docs https://docs.scipy.org/doc/numpy-1.13.0/reference/generated/numpy.flip.html

New in version 1.12.0.

Can you check your numpy version? Just run

>>> import numpy as np
>>> np.version.version

from the interactive shell.

See numpy reverse multidimensional array for an alternative method to flipping an array.

Sign up to request clarification or add additional context in comments.

4 Comments

pip show numpy returns Version: 1.7.1 I don't really know python, I just need to get this script to work, so I can't provide diff. method.
Start Python by running python from the terminal. Then enter the commands to check the version of numpy that is actually being used.
ok, still 1.7.1. so should I ask my webhost to try upgrade for 1.12.0? or any easy command to this myself?
Yeah, so your Numpy is too old. It's just pip install numpy --upgrade, but maybe it's better to ask for support.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.