python import numpy无法_导入numpy在IDLE中不起作用

1586010002-jmsa.png

I have python3.5.2 installed on a windows10 machine(Adding into the pythonpath is included in the setup with new python). I ,then, installed the Anaconda(4.2.0) version. At the command prompt when i run the python interpreter and import numpy it works fine. But when i save it as a script and try running from the IDLE, it gives

Traceback (most recent call last):

File "C:\Users\pramesh\Desktop\datascience code\test.py", line 1, in

from numpy import *

ImportError: No module named 'numpy'

I don't know what the problem is. I donot have any other python version installed.

解决方案

You do have two versions of python installed: the CPython 3.5.2 distribution you mention first, and the Anaconda 4.2.0 Python distribution you then mention. Anaconda packages a large number of 3rd party packages, including Numpy. However, the CPython 3.5.2 installation available on python.org only ships with the standard library.

These two python installs have separate package installations, so having Anaconda's numpy available doesn't make it available for the CPython install. Since you're starting the Idle with shipped with CPython, which doesn't have numpy, you're seeing this error. You have two options:

Install numpy for CPython. See numpy documentation for details on how to do this, but it may be difficult.

Use the version of Idle included with Anaconda. This should be available in the Anaconda programs folder.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值