Tag Archives: numpy

Pycharm introduces numpy error: ImportError: Importing the multiarray numpy extension module failed. Most likely you are trying to import a failed build of numpy.

The software is pychar with Anaconda installed

My initial error was that numpy could not be called in pychar, and the error was modulenotfounderror: no module named ‘numpy’. This problem was solved by the blog. In fact, we need to use Anaconda’s python.exe

But when you run the code:

import numpy as np

arr = np.random.randint(1, 9, size=9)
print(arr)

The following error occurred again:

File “C:\python\Anaconda3\lib\site-packages\numpy\core\__ init__. py”, line 26, in < module>
raise ImportError(msg)
ImportError:
Importing the multiarray numpy extension module failed. Most
likely you are trying to import a failed build of numpy.
If you’re working with a numpy git repo, try `git clean -xdf` (removes all
files not under version control). Otherwise reinstall numpy.

Or error, after their own exploration, found a solution, the original version of their numpy is too low! The solution is as follows:

 

How to update?The best way is to use anacon to update all of them uniformly without making mistakes. The method is as follows:

Step 1: first, start cmd.exe as an administrator
Step 2: to upgrade CONDA (you need to upgrade CONDA before upgrading Anaconda) is: CONDA update CONDA
Step 3: to upgrade anconda is: CONDA update Anaconda
Step 4: to upgrade Spyder is: CONDA update Spyder

Step 3: to upgrade Anaconda

Then restart pychar and run the code:

import numpy as np

arr = np.random.randint(1, 9, size=9)
print(arr)

Finally it worked! And when you type pycharm there are also function parameters and other prompts, by the way in the windows environment: ctrl+p will come up with parameter prompts.
Run the results.

[1 2 2 4 7 1 8 7 4]

Python2.7 Install Numpy Error:is not a supported wheel on…

The error message of installing numpy in python2.7 is as follows:

C:\Python27\Scripts>pipinstall"numpy-1.9.2+mkl-cp26-none-win_amd64.whl"
numpy-1.9.2+mkl-cp26-none-win_amd64.whlisnotasupportedwheelonthisplatfor
m.

Error reason:

In fact, my Python version is 2.7 and my numpy version is 2.6, so it’s wrong

Solution:

See: file name.wheel is not supported wheel on this platform

Download the numpy installation file of the corresponding version of Python:

Download the file version cp27

Re install run:

C:\Python27\Scripts>pipinstall"numpy-1.9.2+mkl-cp26-none-win_amd64.whl"
numpy-1.9.2+mkl-cp26-none-win_amd64.whlisnotasupportedwheelonthisplatfor
m.

C:\Python27\Scripts>pipinstallC:\python-tools\numpy-1.9.2+mkl-cp27-none-win_am
d64.whl
Processingc:\python-tools\numpy-1.9.2+mkl-cp27-none-win_amd64.whl
Installingcollectedpackages:numpy
Foundexistinginstallation:numpy1.9.2
Uninstallingnumpy-1.9.2:
Successfullyuninstallednumpy-1.9.2
Successfullyinstallednumpy-1.9.2

C:\Python27\Scripts>

Successfully installed

Verify the installation success in shell:

>>>fromnumpyimport*
>>>

InvalidArgumentError (see above for traceback): You must feed a value for placeholder tensor ‘…

I found a problem when you use tensorboard for visualization: if you define

MERGED = tf.summary.merge_ all();

After this operation, if you use it alone SESS.run ([merge]), the above error will be reported

At this point, you should work with other pigs instead SESS.run ([train, merged]), this error will not be reported again after the change

It’s hard for me to explain the specific reasons. Before, I checked this error for a long time and found some solutions, but none of them solved my problem

https://stackoverflow.com/questions/35114376/error-when-computing-summaries-in-tensorflow

Later, I referred to a GitHub program and changed it according to its appearance.

# -*- coding: utf-8 -*-
"""
Created on Wed Oct 31 17:07:38 2018

@author: LiZebin
"""

from __future__ import print_function
import numpy as np
import tensorflow as tf

tf.reset_default_graph()
SESS = tf.Session()

LOGDIR = "logs/"

X = np.arange(0, 1000, 2, dtype=np.float32)
Y = X*2.3+5.6
X_ = tf.placeholder(tf.float32, name="X")
Y_ = tf.placeholder(tf.float32, name="Y")
W = tf.get_variable(name="Weights", shape=[1],
                    dtype=tf.float32, initializer=tf.random_normal_initializer())
B = tf.get_variable(name="bias", shape=[1],
                    dtype=tf.float32, initializer=tf.random_normal_initializer())
PRED = W*X_+B
LOSS = tf.reduce_mean(tf.square(Y_-PRED))
tf.summary.scalar("Loss", LOSS)
TRAIN = tf.train.GradientDescentOptimizer(learning_rate=0.0000001).minimize(LOSS)
WRITER = tf.summary.FileWriter(LOGDIR, SESS.graph)
MERGED = tf.summary.merge_all()

SESS.run(tf.global_variables_initializer())
for step in range(20000):
    c1, c2, loss, RS, _ = SESS.run([W, B, LOSS, MERGED, TRAIN], feed_dict={X_:X, Y_:Y})   ####If you write RS=SESS.run(MERGED) after it alone, it will report the same error as before
    WRITER.add_summary(RS)
    if step%500 == 0:
        temp = "c1=%s, c2=%s, loss=%s"%(c1, c2, loss)
        print(temp)
SESS.close()