python中无法import numpy_无法导入numpy

本文介绍了在OS X Mavericks上安装Python并尝试导入numpy模块时遇到的问题及解决方法。作者在使用官方Python环境时发现无法找到numpy模块,通过检查pip安装路径和Python解释器路径后,建议使用Anaconda等Python发行版来更方便地安装科学计算所需的库。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

I'm on OS X Mavericks and new to Python. I have the Apple python environment and installed the official one from python.org.

When I try to import numpy from the python interpreter I get that the module can't be found.

import numpy

Traceback (most recent call last):

File "", line 1, in

ImportError: No module named numpy

>>>

When I run:

$ pip install numpy

Requirement already satisfied (use --upgrade to upgrade): numpy in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python

When I run the following commands on the terminal I get the following:

$which python

/Library/Frameworks/Python.framework/Versions/2.7/bin/python

$which pip

/Library/Frameworks/Python.framework/Versions/2.7/bin/pip

what to do because I'm going crazy!!!

解决方案

I had a similar problem with numpy and other libraries common to scientific packages like matplotlib. You might try installing a Python distribution package like Anaconda, which includes several other useful libraries similar to numpy. Install link here: https://store.continuum.io/cshop/anaconda/. Best of luck.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值