我想为python(neuron)安装一个模块,但该脚本不适用于mac OS X.
首先我尝试了按摩:
tittorento:nrnpython Dani$ python setup.py install --with-nrnpython=dynamic
File "setup.py", line 79
= [ epre+libdirs[0],epre+libdirs[1] ],
^
SyntaxError: invalid syntax
相应的代码:
hoc_module = Extension(
"neuron.hoc",
["inithoc.cpp"],
library_dirs=libdirs,
= [ epre+libdirs[0],epre+libdirs[1] ],
#extra_objects = [],
libraries = [
"nrnpython",
"nrnoc", "oc", "nrniv", "ivoc",
"memacs",
"meschach", "neuron_gnu",
"nrnmpi",
"scopmath", "sparse13", "sundials",
"readline",
"IVhines",
],
include_dirs = include_dirs,
define_macros=defines
)
如果我注释掉那一行,那就说:
tittorento:nrnpython Dani$ python setup.py install --with-nrnpython=dynamic
Error:
NEURON configure time python:
Python presently executing setup.py: /usr/local/opt/python/bin/python2.7 2.7
These do not match, and they should!
我不知道该怎么做。我需要为我的科学工作设置这个模块。
出现此错误的代码如下:
#setup.py
from distutils.core import setup, Extension
from distutils.sysconfig import get_python_version
import sys
import os
# NRNPYTHON_DEFINES which were enabled at configure time
extern_defines = ""
nrnpython_exec = ""
nrnpython_pyver = ""
nrn_srcdir = "."
build_rx3d = 0
ivlibdir = "/Applications/NEURON-7.3/iv/x86_64/lib"
if ivlibdir == "" :
ivlibdir = '.'
destdir = os.getenv("DESTDIR")
if not destdir:
destdir = ""
instdir = destdir + "/Applications/NEURON-7.3/iv"
if nrn_srcdir[0] != '/' :
nrn_srcdir = '../../' + nrn_srcdir
if nrnpython_pyver!=get_python_version():
print "Error:"
print "NEURON configure time python: "+nrnpython_exec+" "+ nrnpython_pyver
print "Python presently executing setup.py: "+sys.executable+" "+ get_python_version()
print "These do not match, and they should!"
sys.exit(1)
ldefs = extern_defines.split('-D')
# if using MPI then at least for linking need special paths and libraries
mpicc_bin = "gcc"
mpicxx_bin = "g++"
import os
os.environ["CC"]=mpicc_bin
os.environ["CXX"]=mpicxx_bin
# apparently we do not need the following
#################################
## following http://code.google.com/p/maroonmpi/wiki/Installation
## hack into distutils to replace the compiler in "linker_so" with mpicxx_bin
#
#import distutils
#import distutils.unixccompiler
#
#class MPI_UnixCCompiler(distutils.unixccompiler.UnixCCompiler):
# __set_executable = distutils.unixccompiler.UnixCCompiler.set_executable
#
# def set_executable(self,key,value):
# print "MPI_UnixCCompiler ", key, " | ", value
# if key == 'linker_so' and type(value) == str:
# value = mpicxx_bin + ' ' + ' '.join(value.split()[1:])
#
# return self.__set_executable(key,value)
#
#distutils.unixccompiler.UnixCCompiler = MPI_UnixCCompiler
#################################
include_dirs = [nrn_srcdir+'/src/oc', '../oc', nrn_srcdir+'/src/nrnmpi']
defines = []
libdirs = [destdir + "/Applications/NEURON-7.3/iv/x86_64/lib",
ivlibdir
]
epre='-Wl,-R'
hoc_module = Extension(
"neuron.hoc",
["inithoc.cpp"],
#library_dirs=libdirs,
#= [ epre+libdirs[0],epre+libdirs[1] ],
#extra_objects = [],
libraries = [
"nrnpython",
"nrnoc", "oc", "nrniv", "ivoc",
"memacs",
"meschach", "neuron_gnu",
"nrnmpi",
"scopmath", "sparse13", "sundials",
"readline",
"IVhines",
],
include_dirs = include_dirs,
define_macros=defines
)
# specify that the data_files paths are relative to same place as python files
# from http://stackoverflow.com/questions/1612733/including-non-python-files-with-setup-py
from distutils.command.install import INSTALL_SCHEMES
for scheme in INSTALL_SCHEMES.values():
scheme['data'] = scheme['purelib']
ext_modules = [hoc_module]
if build_rx3d:
try:
import numpy
# TODO: do we need to use os.path.join?
src_path = nrn_srcdir + '/share/lib/python/neuron/rxd/geometry3d/'
build_path = '../../share/lib/python/neuron/rxd/geometry3d/'
include_dirs = [nrn_srcdir + '/share/lib/python/neuron/rxd/geometry3d', '.', numpy.get_include()]
ext_modules=[hoc_module,
Extension("neuron.rxd.geometry3d.graphicsPrimitives",
sources=[build_path + "graphicsPrimitives.cpp"],
include_dirs=include_dirs),
Extension("neuron.rxd.geometry3d.ctng",
sources=[build_path + "ctng.cpp"],
include_dirs=include_dirs),
Extension("neuron.rxd.geometry3d.surfaces",
sources=[build_path + "surfaces.cpp", src_path + "marching_cubes2.c", src_path + "llgramarea.c"],
include_dirs=include_dirs)]
except:
pass
packages=['neuron','neuron.neuroml','neuron.tests', 'neuron.rxd']
if build_rx3d:
packages +=['neuron.rxd.geometry3d']
setup(name="NEURON", version="7.4",
description = "NEURON bindings for python",
package_dir = {'':instdir+'/share/nrn/lib/python'},
packages=packages,
data_files = [('neuron', [nrn_srcdir + '/share/lib/python/neuron/help_data.dat'])],
ext_modules=ext_modules
)
答案 0 :(得分:0)
我认为这个安装指南非常好,适用于os x: http://labrigger.com/blog/2012/08/30/getting-neuron-to-run-on-os-x-with-python-support/
也许您在调用install命令之前忘记构建模块?
编辑:我建议使用工具" pip"用于安装模块和软件包,但是2012年的一篇文章称神经元无法通过" pip"对于os x,但对于Windows和Linux。这篇文章已有三年了,所以现在可能支持os x了。