PyDev is trying to import non-test-related files? - pydev

When I try to auto-discover and run my tests in PyDev I get many import errors...
For example:
Finding files... done.
Importing test modules ... Traceback (most recent call last):
File "C:\Users\User\Documents\eclipse\dropins\plugins\org.python.pydev.debug_2.4.0.2012020116\pysrc\pydev_runfiles.py", line 307, in __get_module_from_str
mod = __import__(modname)
ImportError: No module named docs.conf
ERROR: Module: docs.conf could not be imported (file: C:/Users/User/Documents/workspaces/workspace1/test/docs/conf.py).
done.
As you can see the "conf.py" file is just a file that is needed for documentation: not actual code. How do I limit PyDev from being over-zealeous when searching for tests?

This is currently possible only in the latest PyDev nightly build.
Go to: window > preferences > pydev > pyunit and add a parameter: --include_files=test*.py
This will be actually released on PyDev 2.6.0.
To grab the nightly build, see: http://pydev.org/download.html

Related

Using Eclipse CDT with the Firefox Nightly code

I downloaded Mozilla-central and built it. I am able to run Firefox Nightly using ./mach run.
Now I am following the instructions of MDN on how to use Eclipse CDT with Mozilla code.
I downloaded Eclipse CDT on my mac and installed it. When I execute the following command:
./mach build-backend -b CppEclipse
It raises an exception saying: Failed to launch eclipse to import project. Ensure 'eclipse' is in your PATH and try again
I tried to add the eclipse's directory (Applications/Eclipse.app) to my PATH environment variable but I still get the same error.
Here is the complete trace:
0:00.46
/Users/****/src/mozilla-central/obj-ff-dbg/_virtualenvs/init/bin/python
/Users/****/src/mozilla-central/obj-ff-dbg/config.status --backend
CppEclipse Reticulating splines... 0:02.99 File already read.
Skipping:
/Users/****/src/mozilla-central/gfx/angle/targets/angle_common/moz.build
Traceback (most recent call last): File
"/Users/****/src/mozilla-central/obj-ff-dbg/config.status", line 1022,
in
config_status(**args) File "/Users/****/src/mozilla-central/python/mozbuild/mozbuild/config_status.py",
line 146, in config_status
the_backend.consume(definitions) File "/Users/****/src/mozilla-central/python/mozbuild/mozbuild/backend/base.py",
line 143, in consume
self.consume_finished() File "/Users/****/src/mozilla-central/python/mozbuild/mozbuild/backend/cpp_eclipse.py",
line 158, in consume_finished
self._import_project() File "/Users/****/src/mozilla-central/python/mozbuild/mozbuild/backend/cpp_eclipse.py",
line 181, in _import_project
raise Exception("Failed to launch eclipse to import project. " Exception: Failed to launch eclipse to import project. Ensure
'eclipse' is in your PATH and try again
Also, using the command:
./mach ide eclipse
I again get the same message:
Eclipse CDT 8.4 or later must be installed in your PATH. Download:
http://www.eclipse.org/cdt/downloads.php
How can I resolve this issue?
I just need to open Firefox nightly in Eclipse to be able to get the call-graph and navigate through its source code.
Run Eclipse first, then:
1- Command:
ps -ef |grep -i ecli
Output:
501 6410 1 0 2:57pm ?? 0:44.98 /Applications/Eclipse
CPP.app/Contents/MacOS/eclipse 501 6428 6365 0 2:57pm ttys001
0:00.00 grep -i ecli
2- Add the binary to the path:
export PATH=/Applications/Eclipse\ CPP.app/Contents/MacOS/:$PATH
3- Test it:
which eclipse

Cannot import Tensorflow with Eclipse on Ubuntu16.04

The bug happens when I try to import Tensorflow on Eclipse. Tensorflow can
be imported when I directly run the python code without using IDEs (I test it and it works perfectly). I've also tested my codes on PyCharm, it's fine with Pycharm....
I've tested the LD_LIBRARY_PATH,PATH,CUDA_HOME variables with echo. I also tried to directly append the cuda libraries into the Ecplipse pydev interpreter setting. So it is really confusing me. I did face a similar question with another machine, but I solved it by modifying the ~/.bashrc file.
I'm using Ubuntu16.04, python2.7,eclipse Neon3, GTX1080ti.
Any ideas? Following is the bug information:
Traceback (most recent call last): File "/home/zernmern/workspace/test/p1/test.py", line 2, in <module>
import tensorflow as tf
File "/home/zernmern/.local/lib/python2.7/site-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "/home/zernmern/.local/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "/home/zernmern/.local/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 52, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "/home/zernmern/.local/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 41, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/home/zernmern/.local/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/home/zernmern/.local/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in
swig_import_helper_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
ImportError: libcusolver.so.8.0: cannot open shared object file: No such file or directory
Failed to load the native TensorFlow runtime.
Please let me know if more information is needed xD.
Ubuntu 16.04 uses Python 3.5 as the default system version of Python. You say that you are using Python 2.7. Did you install that yourself? It doesn't come with the OS. (And if you don't have a compelling reason to stay with Python 2.7, I would encourage you to switch to Py 3.x anyway, especially since you're working with a cutting-edge package like TensorFlow.)
Once you have two versions of Python on your system, it's easy to lose track of which packages you installed to which version of Python. I would check to see whether you happen to have installed TensorFlow, or parts of it, to the system Python 3.5 instead of your Python 2.7.
Finally, I find the solution from 'PyCharm cannot find library'
As the user 'Laizer' suggested:
The issue is that PyCharm(Here is Eclipse) was invoked from the desktop, and wasn't getting the right environment variables. Solution is to either:
invoke from the command line(i.e. Directly start eclipse by sh),
create a script to set environment and then invoke, and make a link to that script on the desktop,
or set environment variables on the desktop item

ModuleNotFoundError: Python 3.6 does not find modules while Python 3.5 does

I wanted to upgrade my python version from 3.5 to 3.6. Since I am using WinPython, I have downloaded and installed the recent version just as I did it before with version 3.5.
However, if I use version 3.6 I get a ModuleNotFoundError whenever I import a self-created module. A minimal example: I created a file t1.py that contains only a pass statement and a file t2.py containing the following code:
import t1
print("done")
Both files are in the same folder D:\MyProject\src. Now when I run the file with python 3.5, everything works fine:
'C:\Program Files\WinPython-64bit-3.5.1.2\python-3.5.1.amd64\python.exe' D:\MyProject\src\t2.py
done
However, with python 3.6 I get
'C:\Program Files\WinPython-64bit-3.6.0.1Qt5\python-3.6.0.amd64\python.exe' D:\MyProject\src\t2.py
Traceback (most recent call last):
File "D:\MyProject\src\t2.py", line 6, in <module>
import t1
ModuleNotFoundError: No module named 't1'
I ran out of ideas what the issue could be and would appreciate new inspiration.
Would this work ? in t2.py
import os
__path__=[os.path.dirname(os.path.abspath(__file__))]
from . import t1
print("t2 done")
Python-3.6 changes its way of working, with the "python._pth" file next to python.exe (instead of "pyvenv.cfg" in previous versions)
If you don't want to modify your source, then you have to add "D:\MyProject\src" line in Python._pth file, or a relative path to it from python._pth location. in my example, it works with:
python36.zip
DLLs
Lib
.
..\test
import site
"http://bugs.python.org/issue29578?#ok_message=msg%20287921%20created%0Aissue%2029578%20message_count%2C%20messages%20edited%20ok&#template=item"
Other, simpler solution if you have no system-installed python: rename the "python._pth" file, next to "python.exe", as "pythonzz._pth"
The Python "Windows" maintainer just wrote that the simpler solution should be ok also with Python-3.6.0.

API 'QString' has already been set to version 1 on Eclipse

I'm getting following error on starting debug session in Eclipse for my code which uses Enthought Mayavi and PyQt as well.
Here is the error log in the console.
pydev debugger: starting (pid: 2208)
Traceback (most recent call last):
File "D:\eclipse\plugins\org.python.pydev_3.7.1.201409021729\pysrc\pydevd.py",
line 2090, in
debugger.run(setup['file'], None, None)
File "D:\eclipse\plugins\org.python.pydev_3.7.1.201409021729\pysrc\pydevd.py",
line 1547, in run
pydev_imports.execfile(file, globals, locals) # execute the script
File "D:\src\Candls_PyQt\src\application.py", line 10, in
sip.setapi("QString",2)
ValueError: API 'QString' has already been set to version 1
Here is my code snippet.
from traits.etsconfig.api import ETSConfig
ETSConfig.toolkit = 'qt4'
import sip
sip.setapi("QString",2)
sip.setapi("QVariant",2)
from PyQt4 import QtCore, QtGui, uic
This was an issue introduced in the latest version of the debugger.
The bug in PyDev is: https://sw-brainwy.rhcloud.com/tracker/PyDev/452 (it was fixed already but it's still not in a released version).
A workaround for now would be manually applying the fix: https://github.com/fabioz/Pydev/commit/af39f23bc884e9514aaaeede7b6e77e22b6823f6 in your local version of pydev_monkey_qt.py (inside eclipse/plugins/org.python.pydev/pysrc)

Configuring Pydev(Eclipse) to Use Sage

I am trying to utilize the Eclipse IDE environment with SAGE using the Pydev extension.
I am following these steps as outline here at http://groups.google.com/group/sage-support/browse_thread/thread/628b80e6bebcc317
Executing a simple code as
import sys
from sage.all import *
print ("2")
gives me an error with the following traceback
Traceback (most recent call last):
File "/Users/username/Documents/eclipse/python/test2.py", line 2, in <module>
from sage.all import *
File "/Users/username/Desktop/sage/local/lib/python2.6/site-packages/sage/all.py", line 63, in <module>
from sage.ext.c_lib import _init_csage, sig_on_count
ImportError: dlopen(/Users/username/Desktop/sage/local/lib/python2.6/site- packages/sage/ext/c_lib.so, 2): Library not loaded: libcsage.dylib
Referenced from: /Users/username/Desktop/sage/local/lib/python2.6/site-packages/sage/ext/c_lib.so
Reason: image not found
As by the instructions, trying to execute eclipse from the terminal window(OSX Lion) by the following
$sage -sh
$eclipse
only gives me the following traceback
-bash: -sh: command not found
Any help would be appreciated, notebook() ide of SAGE works fine but Id like to be able to use the Eclipse IDE environment rather than an online server browser.
Sounds as if you entered the '$'. It is sometimes used to indicate a line of input at the terminal. You should also make sure, that sage and eclipse are in your PATH, or you could use the complete path in both cases
~/path/to/sage -sh
~/path/to/eclipse