我正在尝试将PyROOT设置为与Mac OS X Yosemite上的Pycharm 4配合使用。
我已经安装了ROOT(本地),启用了python选项,并设置了所有必要的环境路径。
echo $PYTHONPATH
/Users/natalia/Software/root/lib:/Users/natalia/Software/root/bin:/Users/natalia/Software/root
从shell解释器中可以正常工作:
python
Python 2.7.6 (default, Sep 9 2014, 15:04:36)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import ROOT
>>> ROOT.__file__
'/Users/natalia/Software/root/lib/ROOT.pyc'
>>>
在Pycharm中,我尝试使用Preferences-> Project Interpreter-> More-> Show paths ...
将这些路径添加到解释器中显示的路径如下:
file:///Library/Python/2.7/site-packages/pip-6.1.1-py2.7.egg
file:///Users/natalia/Software/root/lib
file:///System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7
file:///System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin
file:///System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac
file:///System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages
file:///System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python
file:///System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk
file:///System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload
file:///System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC
file:///Library/Python/2.7/site-packages
file:///Users/natalia/Software/root/bin
file:///Users/natalia/Software/root
我在Pycharm中创建了以下文件:
import os
os.system("echo $PYTHONPATH")
import ROOT
运行时,它会返回:
Traceback (most recent call last):
/Users/natalia/Software:/Users/natalia/Software/root:/Users/natalia/Work/Projects/untitled
File "/Users/natalia/Work/Projects/untitled/l.py", line 3, in <module>
import ROOT
ImportError: No module named ROOT
请注意,Pycharm中从python打印的PYTHONPATH如何包含(对于我不知道的原因)实际包含ROOT.pyc文件的路径,即:&#39; /用户/纳塔利亚/软件/根/ lib中&#39;
我也试过做
的肮脏伎俩os.system("export PYTHONPATH=$PYTHONPATH:/Users/natalia/Software/root/lib")
但我发现如果之后打印它,它实际上并没有改变路径。
我对Pycharm从哪里获取路径感到困惑。 任何可能的解决方案都将受到欢迎并非常感谢
答案 0 :(得分:3)
你可能已经想到了这一点,但以防万一......
import sys
sys.path.append('/Applications/Misc/root/lib')
import ROOT
print ROOT.TTimeStamp().AsString()
将该搜索路径添加到Python(扩展名为&amp; PyCharm);该片段在PyCharm中为我提供了以下输出:
/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7
/Users/rrios/PycharmProjects/untitled/dummy.py
Thu, 02 Jul 2015 01:07:57 UTC +628998000 nsec
Process finished with exit code 0