我有一個虛擬環境my_env,我在其中安裝了Anaconda。當我鍵入導入錯誤:Anaconda numpy(numpy和Anaconda已經安裝,virtualenv)
which python
我得到:
/user/pkgs/anaconda2/envs/my_env/bin/python
我有進口沒有錯誤numpy的位置:
(my_env) [email protected]:~/my_dir$ python
Python 2.7.12 |Continuum Analytics, Inc.| (default, Jul 2 2016, 17:42:40)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
>>> import numpy as np
>>>
但是,當我說 '進口numpy的是NP' 在Python程序和從shell腳本運行,我得到:
(my_env) [email protected]:~/mydir$ ./program.sh
Traceback (most recent call last):
File "../python_program.py", line 3, in <module>
import numpy as np
ImportError: No module named numpy
我該如何解決這個問題?
編輯:我被問到什麼是在program.sh。簡短的答案是我在一個循環中運行不同的參數。長的答案是:
#/bin/bash
i=0
while read a1 b1 c1 d1 e1 f1 g1 h1 i1
do
i=$(($i+1))
mkdir RUN_EXP$i
cp $a1 RUN_EXP$i
cd RUN_EXP$i
../python_program.py --filename $a1 --reps $b1 --pop $c1 --susc $d1 --exp_trans $e1 --inf_period $f1\ $g1 --eps $h1\ $i1
cd ..
done < readparas.txt
文件readparas.txt具有包含文件名,代表,流行,SUSC,exp_trans,inf_period線,和每股收益如下:
run_1.txt 50 162 0.30 0.1 5 9 0.1 0.25
run_1.txt 50 162 0.30 0.3 5 9 0.1 0.25
...
是什麼在'program.sh'中? – DyZ
@DYZ請參閱上面的修改。 – StatsSorceress