16

我今天在 Mac OSX 10.5.8 上下载了 Eclipse (3.5.2) 的 Pydev 插件。为了能够使用 Pydev,我需要在 Eclipse 中配置解释器。我不清楚我到底需要在这里做什么,或者这一步做什么。我想确保当我使用 Pydev 从 Eclipse 运行程序时,它使用我安装的 Enthought Python Distribution (EPD),并且可以使用 EPD 附带的所有包。有人可以告诉我需要遵循的简单步骤。

如果我点击自动配置,它会显示一堆带有路径的文件夹

/System/Library/Frameworks/Python.Framework/Versions/2.5/...

但是我知道EPD自带的Python是2.6.4版本,所以autoconfig没有选择EPD。

谢谢你的帮助。


更新 - 解决方案

如果其他人有兴趣学习如何做到这一点,请参阅下面 mlvljr 答案中的第一个链接。使用那里的解决方案,除了解决方案中建议的 Shift+Cmd+G 并没有帮助我看到 Python.app 包的内部。要查看它,请使用 Finder 中的“gear”下拉菜单并选择“Show Package Contents”

4

7 回答 7

12

Mac OS 10.6.4:

Selecting the interpreter as /Library/Frameworks/Python.framework/Versions/2.7/Python did not work.

I had to select /Library/Frameworks/Python.framework/Versions/2.7/bin/python

于 2010-10-30T20:43:21.667 回答
10
于 2010-03-18T15:24:00.943 回答
3

For latest versions of Canopy under Mac the correct path seems to be:

/Users/<yourusername>/Library/Enthought/Canopy_32bit/System/bin/python

I tried with ~/.... first but Eclipse didn't seem to like that.

于 2013-05-13T16:45:28.680 回答
2

I've had the same luck!

On top of a Mac X Lion I did the following installations: * Enthought 2.7 (these preconfigures Python 2.7 and a lot of other libraries). * Aptana Studio 3.03 (not beta) with PyDev preconfigured. * Finally, and after some troubles I saw that there was some versions of Python installed on my Mac (and I don't remembre when I installed it). I had to choose the version that justus87 says. Put attention on it because its easy to confuse and is a head break!

Remember, the path of the python file is: /Library/Frameworks/Python.framework/Versions/7.1/bin/python

You need to make sure you point it to the EPD interpreter and not just the regular python 2.7 interpreter. For EPD 7.2 64-bit on mac the path is "/Library/Frameworks/EPD64.framework/Versions/7.2/bin"

于 2011-12-16T09:04:44.040 回答
1

I am running Python 3, so I had to make these changes to get python.exe as my interpreter.

File: C:\EasyEclipse-for-LAMP-1.2.2.2\extensions\pydev-1.3.3\eclipse\plugins\org.python.pydev_1.3.3\PySrc\interpreterInfo.py

Edit all occurrences of "print ..." to "print(...)" (the ... is whatever is being printed), so wrap it in parentheses.

Comment out line 16, since True and False are considered keywords in Python 3.

Save, and you should be able to successfully set C:\Python32\python.exe as the interpreter. I kept the default folders checked.

于 2012-02-16T06:47:43.887 回答
1

I found this tutorial very helpful for this problem - http://www.cs.duke.edu/courses/compsci101/current/resources/install.php

Specifically, step 6:

  1. connect Eclipse to your version of Python (so you can run Python programs within Eclipse) connect Eclipse to your version of Python (so you can run Python programs within Eclipse)
    • open Eclipse and access the Preferences Box (under Window>Preferences on Windows or Eclipse>Preferences on Mac)
    • choose "Pydev" and "Interpreter - Python" from the sidebar
    • press the "New ..." button to tell Eclipse about Python
    • in the resulting dialog box, for the "Interpreter Name" type "Canopy" and for the "Interpreter Executable" type
      • for Windows: "C:\Users\UUU\AppData\Local\Enthought\Canopy\User\python.exe"
      • for Mac: "/Users/UUU/Library/Enthought/Canopy_VVV/User/bin/python"
    • where UUU is your user name on your machine and VVV is the remainder of the directory name (which depends on which version you installed; you should be able to find the right one by browsing to it)
    • choose "Select All" and then click "OK" at the bottom of the resulting dialog box
    • click "OK" at the bottom of the Preferences Box and wait for the changes to take effect when the dialog box to close (you do not need to restart Eclipse)
于 2013-12-09T18:48:10.587 回答
0

If you can get the (Enthought) Canopy distribution working, but are unsure where it's installed to/what PyDev needs, the following worked for me to use that install to identify the right solution, and install it:

start ipython (as it was installed with the Canopy distribution).

do:

import sys; 
for i in sys.path: print( i)

look for the option that ends in: "/bin" ( e.g. mine was: /Users/myUserNameHERE/Library/Enthought/Canopy_32bit/User/bin )

Now the fun part (as it worked for me), go to eclipse's preferences, and under: "Pydev"==> "Interpreter - Python", and select 'New...'

Add in that full path under 'Interpreter Executable" put that path, along with 'python' (on mac [ probably 'python.exe' on windows?] ). For 'Interpreter Name' I put 'Python2.7-Canopy');

PyDev then automatically the other libraries to include ( I checked the boxes to accept its suggestions).

Lastly, you'll need to make sure that your project is using that Interpreter. Ensure either

  • (a) If your project is bound to the default interpreter (for 'Python' and not 'Jython'), move that new 'Python2.7-Canopy' you added (in your workspace Preferences) to be your workspace's default ( using 'Up' to make it first) or
  • (b) Go to the settings for the project, and under 'PyDev - Interpreter/Grammer' select from the requisite dropdown box the name you put (eg. "Python2.7-Canopy")

On my system, all then finally worked, matplotlib, numpy, etc. Yeah!

于 2013-11-06T04:40:16.183 回答