Setting up Pylint with PyDev - pydev

I have installed pylint via easy_install. I can run pylint <filename> with success. But pydev refuses to use it.
I checked "use pylint"
I configured correct path
I updated my python interpreter in eclipse to have pylit in pythonpath
I use Eclipse Galileo
I have build automatically checked
I tried cleaning whole project and no errors
What am I doing wrong?

I'm guessing you may need to mark the folder that contains your code as a source folder. You can do this under project properties.
Project->Properties->PyDev-PYTHONPATH
add relevant folders to the list of sources.

I've noticed that Pydev won't run Pylint on files with dashes (hyphens) the the filename; according to the Pydev devs, '-' is not a valid Python module name character, and it doesn't look like they intend to fix it:
http://sourceforge.net/tracker/index.php?func=detail&aid=1915426&group_id=85796&atid=577329
http://sourceforge.net/tracker/index.php?func=detail&aid=2888890&group_id=85796&atid=577332
As if nobody writes scripts in Python... Grumble grumble...

To provide an alternative solution, pylint can be used as an External Tool in Eclipse. This requires having previously installed the pylint package for a Python installation.
Remember to first have a pylintrc file somewhere where pylint can find it, failing which a "No config file found" error is printed. Typically I would touch pylintrc inside the project directory, and keep the file in version control. For reference, see pylint command-line options.
In Eclipse, select Run, External Tools, External Tools Configurations.... Click the toolbar button to create a New launch configuration. Configure as below or as desired:
Name: pylint
Location: ${system_path:pylint}
Working Directory: ${project_loc}
Arguments: --reports=n "${resource_loc}"
Remember to click inside an open file to switch focus to it before running the above external tool for it. Failing this, an error can occur.
The output of the external tool will by default be printed to the console.
Related: Setting up pep8 as an External Tool in Eclipse

Related

Import problem with numpy on Eclipse 2018-09

I'm have a problem using numpy with the latest Eclipse 2018-09 and PyDev 7.0.3. I'm using the latest Anaconda Python 3.7.0 which includes numpy version 1.15.1
I believe I have PyDev setup properly as I can run and debug python program that do not use numpy.
Whenever I try to "import numpy as np", I get this error:
ImportError:
Importing the multiarray numpy extension module failed. Most
likely you are trying to import a failed build of numpy.
If you're working with a numpy git repo, try git clean -xdf (removes all
files not under version control). Otherwise reinstall numpy.
Original error was: DLL load failed: The specified module could not be found.
I've found a work-around by adding this single directory to the system path (not the PYTHONPATH):
C:\ProgramData\Anaconda3\Library\bin
I do this outside of Eclipse and need to restart Eclipse after changing the system path.
Hopefully, someone can explain the proper way to configure PyDev so that I don't have to pollute my system path.
Thanks!
I have had to do a half 4 or 5 installs of anaconda python in the last half year, and I think every one has been a struggle to get numpy to work. Today I can remember only the final trick that got me past that error:
This system is clean install of Windows 10, and Eclipse version 2019-12(4.14.0) Build id 20191212-1212. 64bit. In Eclipse the Python interpreter (3.7.6) is working otherwise. And Python loads numpy from a command prompt, just not within Eclipse.
In Eclipse Navigator window, right click on a PyDev project and select properties.
On the left select PyDev - Interpreter/Grammar.
On the right 'Click here to configure an interpreter not listed'. (But this will actually configure the listed interpreter.)
Then click on Open interpreter preferences page.
Now in the left tree, select Pydev / Interpreters / Python Interpreter.
On the right lower, choose the Environment Tab, On the far right lower click Add.
In the New Environment Variable window,
in Name enter PATH
in Value enter \anaconda3\Library\bin
Happyness for me! It worked without having to re-start Eclipse.
I had previously added the same path to the user's PATH in the Windows environment settings, without effect. I had earlier checked 'load conda env vars before run', and have left that checked.
In the interpreter configuration (window > preferences > PyDev > Interpreters > Python interpreter), you should be able to select the interpreter you want, go to the environment tab and set the PATH environment variable to be as you want (so, any launch with that interpreter will use the PATH you specified).
Now, I see you're using Anaconda... have you tried checking the Load conda env vars before load? to see if it fixes it for you? (that appears in the package tab when you select the interpreter).

Eclipse Pydev adding PYTHONPATH=../:. before running a pytest module

I am developing something in Python in Eclipse PyDev. Per the instructions from my assignment, I need to run this program like so:
PYTHONPATH=../:. python grade_analysis.py
However I am just running the program with the standard Run button and (no surprise) it's not working correctly. It is a unit test that claims it runs 0 tests.
Does anyone know how to run this specific file with that pythonpath in Eclipse PyDev? I've been playing with settings in the Run Configuration and no luck
You have to configure those paths to be source folders inside of PyDev (a source folder is the folder that should be in the PYTHONPATH).
See: http://www.pydev.org/manual_101_project_conf2.html for details.

Variable project_loc contains no value

In Oxygen, when I attempt to launch an external tool which has the working directory defined as ${project_loc}/docs, Eclipse complains that "Variable references empty selection: ${project_loc}". I currently have the project selected in Package Explorer. I am running in the Pydev perspective. How can I correct this situation?
Not sure what's happening there, but when I created a "New Program" as an external tool and pointed the location to python.exe and working directory with ${project_loc} and as arguments -c "import os;print(os.path.abspath(os.curdir))" it did run and print the project selected in the PyDev Package Explorer properly (so... not much help, but the same thing worked for me).

Installing Maven 3.1.1 on Maverick and working with eclipse-Kepler TLM terminal plugin

I recently installed OS X 10.9 Mavericks. As it does not come with Maven pre installed, I installed Maven 3.1.1 manually. I exported maven and set its path in .bash_profile. It is accessible from command line. But it is not accessible from within eclipse TLM terminal plugin or Wicked Shell plugin.
One workaround I got is, I added same export statement in .bashrc and it is accessible now from within eclipse aforementioned terminal plugins. Is there any better solution for it? Can anybody explain how many .bash* files are there in mac and when each one is initialised ?
In order to have eclipse pick up the new addition to your PATH, you need to edit /etc/launchd.conf to set the environment variable explicitly. Environment variable substitutions such as $PATH will not work. To correct do an echo $PATH in terminal and copy what it returns. Then, add this line to the launchd.conf file and restart your machine.
setenv PATH <your echo $PATH results here>
After, all should return to normal in eclipse. Hope this helps!

How to install and configure the EclipseFP Haskell plugin for Eclipse?

Can somone who has done this tell me exactly what to do? The documentation is lacking and what is there is incomplete and incorrect.
I've got the plugin installed, and told it to usethe GHC installation that I have as part of the Haskell Platform but Run As.. only shows me Run GHCi session. According to the cheat sheet, I should see Haskell Application.
Also missing are instructions for where to find the hugs executable, and the Cabal installation that the Haskell Preferences seems to suggest I should have.
Can anyone point out what I've missed?
I'm a Haskell beginner, hence trying to get Eclipse set up so I can play with it...
It seems that currently there is no way to create a non-interactive launch configuration
via GUI. However, you can do that by manually editing config files. The following instructions work with Eclipse 3.5.2, EclipseFP 2.0.2:
Make sure there exists a GHCI configuration.
Close Eclipse.
Go to directory .metadata/.plugins/org.eclipse.debug.core/launches in the root of your workspace.
There should be a file named something like "Main (project src).launch". Copy it under whatever name you wish, for instance "Run Main.launch"
Open your copied file in a text editor and replace the option --interactive with -e main.
Save the file and start eclipse. You should see the new run configuration "Run Main". When you run it, EclipseFP executes your Main.hs file, redirecting both input and output to the console view.
Also, it seems that you haven't configured cabal yet. You first need to install it (from your distribution repositories, or here if you're using Windows). Then go to Scion and Cabal preferences and point them to your cabal executable. After you click OK the compilation of Scion should start. If it gives you errors, read what packages are missing and install them via cabal install pkg-name. (I had to install happy with --global flag, and for QuickCheck I had to manually set the 2.* version). To rerun Scion compilation, restart Eclipse.