我正在尝试在mac 10.8.4上安装xlrd,以便能够通过python读取excel文件.
我已按照http://www.simplistix.co.uk/presentations/python-excel.pdf上的说明进行操作
我这样做了:
将文件夹解压缩到桌面
在终端,cd到解压缩的文件夹
$ python setup.py安装
这就是我得到的:
running install
running build
running build_py
creating build
creating build/lib
creating build/lib/xlrd
copying xlrd/__init__.py -> build/lib/xlrd
copying xlrd/biffh.py -> build/lib/xlrd
copying xlrd/book.py -> build/lib/xlrd
copying xlrd/compdoc.py -> build/lib/xlrd
copying xlrd/formatting.py -> build/lib/xlrd
copying xlrd/formula.py -> build/lib/xlrd
copying xlrd/info.py -> build/lib/xlrd
copying xlrd/licences.py -> build/lib/xlrd
copying xlrd/sheet.py -> build/lib/xlrd
copying xlrd/timemachine.py -> build/lib/xlrd
copying xlrd/xldate.py -> build/lib/xlrd
copying xlrd/xlsx.py -> build/lib/xlrd
creating build/lib/xlrd/doc
copying xlrd/doc/compdoc.html -> build/lib/xlrd/doc
copying xlrd/doc/xlrd.html …Run Code Online (Sandbox Code Playgroud) 我是编程和尝试导入scipy的新手.
问题:
当我尝试在终端中的python解释器中导入scipy时,它看起来像这样:
[GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import scipy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named scipy
>>>
Run Code Online (Sandbox Code Playgroud)
我似乎正确安装了macports.我可以像上面一样成功导入numpy.
我最初根据http://www.scipy.org/install.html上的"macports"说明安装了scipy
即:
sudo port install py27-numpy py27-scipy py27-matplotlib py27-ipython +notebook py27-pandas py27-sympy py27-nose
Run Code Online (Sandbox Code Playgroud)
我也遵循了这篇文章: Python不会识别MacPorts安装的软件包
但似乎无法为自己找到答案
澄清:
当我运行"哪个python"时,我得到了
/usr/bin/python
Run Code Online (Sandbox Code Playgroud)
当我运行"端口内容py27-packagename"时,我得到了
Port py27-packagename is not installed.
Run Code Online (Sandbox Code Playgroud)
提前致谢
作为这篇文章的后续跟进:
一个单独的问题:
作为一名初学程序员,我被教导只从函数中返回一个东西.
一个.返回多个东西有什么隐藏的问题吗?
湾 如果是这样,并且我想从一个长函数返回2个列表(即不调用2个单独的类似函数),那么从列表中创建一个元组有什么问题吗?
谢谢
我有一个零的3d数组,我想用1d数组填充它:
In [136]: C = np.zeros((3,5,6),dtype=int)
In [137]: C
Out[137]:
array([[[0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0]],
[[0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0]],
[[0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, …Run Code Online (Sandbox Code Playgroud) python ×3
installation ×2
arrays ×1
function ×1
macports ×1
numpy ×1
python-2.7 ×1
scipy ×1
xlrd ×1