【问题标题】:How to use numpy with cygwin如何在 cygwin 中使用 numpy
【发布时间】:2011-01-17 07:29:49
【问题描述】:

我有一个调用一些 python 脚本的 bash shell 脚本。我正在使用 cygwin 运行 Windows,它在 /usr/bin/python 中有 python。我还安装了 python 和 numpy 作为 windows 包。当我从 cygwin 执行脚本时,我得到一个 ImportError - 没有名为 numpy 的模块。我尝试从 Windows shell 运行,但 bash 脚本没有运行。有任何想法吗?我的脚本在下面

for target in $(ls large_t) ;  
do 
./emulate.py $target ;  #
done | sort | gawk '{print $2,$3,$4,$5,$6 > $1}{print $1}' | sort | uniq > frames

#frames contains a list of filenames, each files name is the timestamp 
rm -f video
touch video

# for each frame
for f in $(cat frames)
do
./make_target_ant.py $f 
cat $f.bscan >> video 
done

谢谢

【问题讨论】:

    标签: python cygwin numpy


    【解决方案1】:

    Windows python 和 Cygwin Python 是独立的;如果您使用的是 Cygwin 的 Python,则需要在 cygwin 中安装 numpy。

    如果您更喜欢使用 Windows python,您应该可以通过以下任一方式从 bash 脚本中调用它:

    • 直接调用windows可执行文件:
      c:/Python/python.exe ./emulate.py
    • 将 hash-bang 更改为指向 Windows 安装:
      脚本中的#!c:/Python/python.exe,而不是#!/usr/bin/env python#!/usr/bin/python
    • 在脚本运行期间将 Windows 的 python 放在 Cygwin python 之前的路径中:
      PATH=c:/Python/:$PATH ./emulate.py
      其中emulate.py使用/bin/env运行python的方法。

    【讨论】:

      【解决方案2】:

      安装的 NumPy 用于 Windows Python,而不是 cygwin Python。从针对 cygwin Python 构建的源代码安装 NumPy,或者从 cygwin 安装程序(如果存在)安装它。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2017-07-08
        • 1970-01-01
        • 2010-09-24
        • 2011-04-18
        • 1970-01-01
        • 2017-11-14
        • 2023-03-09
        • 1970-01-01
        相关资源
        最近更新 更多