Configuring Pydev Interpreter in Eclipse to use Enthought Python Distribution

假装没事ソ 提交于 2019-11-29 11:37:54

问题


I downloaded Pydev plugin for Eclipse (3.5.2) today on Mac OSX 10.5.8. To be able to use Pydev, I need to configure the interpreter in Eclipse. I am not clear what exactly I need to do here, or what this step does. I want to make sure that when I run programs from Eclipse using Pydev, it uses the Enthought Python Distribution (EPD) I have installed, and can use all the packages that come with EPD. Can someone please tell me simple steps that I need to follow.

If I click on autoconfig, it shows a bunch of folders with the path

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

But I know that the Python that came with EPD is version 2.6.4, so autoconfig is not choosing EPD.

Thanks for any help.


UPDATE - solution

If anyone else is interested in learning how to do this, see the first link in the answer by mlvljr below. Use the solution there EXCEPT that as suggested in the solution, Shift+Cmd+G, did not help me see inside the Python.app package. To look inside it, use the "gear" drop down menu in the Finder and choose "Show Package Contents"


回答1:


At least on Windows, this seems to doable via:

  1. [Navigate Eclipse menus] "Window"->"Preferences"->"PyDev"->"Interpreter - Python"-> "New" (which is next to "Auto Config" you tried to use, if I get it right)

  2. [Type or paste into textboxes] "Interpreter Name", "Interpreter Executable"

  3. Click "OK" :))

[UPDATE]

From the Enthought Python Distribution Readme.txt (EPD.mkpg/Contents/Resources/Readme.txt in epd-6.1-1-macosx-i386.dmg EPD disk 32-bit MacOS disk image):

Applications are installed into /Applications/EPD32-6.1
and the underlying Python framework into /Library/Frameworks/Python.framework/Versions/6.1

So, Interpreter Executable must be:

/Library/Frameworks/Python.framework/Versions/6.1/python

You can supply (almost) any Interpreter Name you like. :)

Hope this helps.

[EDIT]

If this does not help, google search for “Error getting info on interpreter” gives the following (the problem may have to do with Eclipse version (older have bugs) and the symlink vs actual path problem):

  1. Installing PyDev on OS X 10.5.2

  2. [Pydev-users] [pydev - Users] mayapy on PyDev Maya Python is running on OSX

  3. Cannot set python interperter in preferences - ID: 1523582 (unfold "comments" there)




回答2:


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




回答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.




回答4:


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"




回答5:


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.




回答6:


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)



回答7:


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!



来源:https://stackoverflow.com/questions/2469849/configuring-pydev-interpreter-in-eclipse-to-use-enthought-python-distribution

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!