尝试Imp时Python命令提示符消失

2024-04-27 03:51:20 发布

您现在位置:Python中文网/ 问答频道 /正文

当试图在解释器中导入库(它是运行numerical neuronal simulations的“neuron”库)时,我只是无限期地丢失命令提示符而没有出现错误:

kjb:~ ken$ python
Python 2.7.8 |Anaconda 1.9.0 (x86_64)| (default, Jul  2 2014, 15:36:00) 
...
>>> import neuron
_

下划线表示光标。你知道吗

我知道这很可能是神经元本身的问题,因为其他模块,如数学导入时没有问题,但是我想知道应该如何继续找出错误?我在这里相当缺乏经验。你知道吗

谢谢!你知道吗


Tags: default错误numericalanaconda解释器x86jul命令提示符
1条回答
网友
1楼 · 发布于 2024-04-27 03:51:20

一般来说,通过先用-python标志启动NEURON,将python与NEURON结合使用会更容易:

nrniv -python

或者

nrgui -python

这从python解释器开始:

NEURON   VERSION 7.4 (1373:f15dcfc7847b) f15dcfc7847b
Duke, Yale, and the BlueBrain Project   Copyright 1984-2015
See http://www.neuron.yale.edu/neuron/credits

然后可以在其中运行python命令:

>>> import sys
>>> sys.version_info
sys.version_info(major=2, minor=7, micro=6, releaselevel='final', serial=0)
>>> quit()

更具挑战性的方法是先启动python,然后导入NEURON库:

$ python
Python 2.7.11 (default, Dec  5 2015, 14:44:47) 
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.1.76)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import neuron
NEURON   VERSION 7.4 (1373:f15dcfc7847b) f15dcfc7847b
Duke, Yale, and the BlueBrain Project   Copyright 1984-2015
See http://www.neuron.yale.edu/neuron/credits

要启动python然后导入NEURON库,您需要:

在MS Windows上,install PyNEURON

pip install PyNEURON

在其他操作系统上,从源代码编译NEURON并设置NEURON python库

  1. Compile NEURON from source with python support
  2. Setup the NEURON library for python

相关问题 更多 >