ImportError when trying to run a python unittest with pydev - python

I am getting the following error when trying to run a module as a python unittest with PyDev.
Finding files...
['C:\\Projectos\\spa\\sensor\\src\\test\\test_sensor.py'] ... done
Importing test modules ... Traceback (most recent call last):
File "C:\eclipse\plugins\org.python.pydev.debug_1.6.3.2010100513\pysrc\runfiles.py", line 342, in __get_module_from_str
mod = __import__(modname)
ImportError: No module named :\Projectos\spa\sensor\src\test\test_sensor
ERROR: Module: :\Projectos\spa\sensor\src\test\test_sensor could not be imported.
done.
I noticed the path in the ERROR: Module: line starts with ":\" but I don't know what's causing it.
Any ideas?
Thank you.

Turns out pydev does not play well with cygwin's python.
Installed python 2.7 for windows and it works.

Related

Pyp3 gives ModuleNotFoundError even if packaged is install

So I'm trying to figure out if I can speed up my code. For that purpose I installed pyp3. But when I try to run the python file using pyp3 I get error in the first line itself ModuleNotFoundError, But when I use simple python my code works smoothly. Is it due to python version difference ? I'm new to pyp3. Any suggestion/help would be appreciated. Thankyou
pypy3 main_feature_extraction.py
Traceback (most recent call last):
File "main_feature_extraction.py", line 1, in <module>
from dotenv import find_dotenv, load_dotenv
ModuleNotFoundError: No module named 'dotenv'

twisted module not found error from Python Flasky

I am having trouble in running a flask file that is manager.py on Windows 10. Although I installed requirements, it still aborts an import error.What's funny is the errors are different in PyCharm and cmd. And I activated the same virtual environment.I will appreciate it if someone can help me!
In PyCharm:
Traceback (most recent call last):
File "C:/Users/Administrator/Desktop/Online-serial-debugging/manage.py", line 6, in <module>
from app import create_app
File "C:\Users\Administrator\Desktop\Online-serial-debugging\app\__init__.py", line 2, in <module>
from flask.ext.twisted import twisted
File "C:\Users\Administrator\Desktop\online\Online-serial-debugging\enve\lib\site-packages\flask\exthook.py", line 87, in load_module
raise ImportError('No module named %s' % fullname)
ImportError: No module named flask.ext.twisted.twisted
Process finished with exit code 1
In CMD:
(enve) C:\Users\Administrator\Desktop\online\Online-serial-debugging>python manage.py
Traceback (most recent call last):
File "manage.py", line 5, in <module>
from flask.ext.script import Manager
ImportError: No module named flask.ext.script
Here are my requirments.txt:
construct==2.5.2
dominate==2.1.16
Flask==0.10.1
Flask-Bootstrap==3.3.5.3
Flask-Moment==0.5.0
Flask-Twisted==0.1.1
Flask-Script==2.0.5
itsdangerous==0.24
Jinja2==2.7.3
MarkupSafe==0.23
observable==0.1.0
pyserial==2.7
six==1.10.0
Twisted==15.4.0
txsockjs==1.2.2
pypiwin32
Werkzeug==0.10.4
zope.interface==4.1.2
Please fix your import statement as follows, and could you try?
from flask_script import Manager
EDIT
Sorry, even using flask.ext.{}, it seems still works.
If you run the following command, what come back?
pip install Flask-Script==2.0.5
It means that 'Flask-Script' was not installed, check your 'pip freeze'.
Was there any error when installing the requirements? If so, try to identify the issue.
Try installing it:
$ pip install Flask-Script
OK. The problem is solved.orz. My command line is :
python manage.py
Actually, I used the Python interpreter in system path by mistake.And I run this command :
./enve/Scripts/python.exe manage.py
There are no import errors again, thank you who answered me still.

sompy Module Import Error

I can't import the sompy module even though I installed it successfully, and it appears in the modules list of my python environment:
When I try to import the sompy module using the following statement:
import sompy
I get the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'sompy'
What's wrong?
Which interpreter/IDE are you using? If using PyCharm, the problem could be that PyCharm hasn't identified a root folder for your .py project.
I would try and recreate the root folder as a subfolder and right click > Make source directory.

GDB pretty printing ImportError: No module named 'printers'

I'm trying to add pretty printing for STL in my GDB on Ubuntu 14.04. Some details on the tools:
OS: Ubuntu 14.04
gdb version: 7.7
python version: 2.7.6
python3 version: 3.4.0
But after I setup exactly as what the instruction said. I still get the following errors:
Traceback (most recent call last):
File "<string>", line 3, in <module>
File "/home/jerry/myLib/gdb_stl_support/python/libstdcxx/v6/__init__.py", line 19, in <module>
from printers import register_libstdcxx_printers
ImportError: No module named 'printers'
/home/jerry/.gdbinit:6: Error in sourced command file:
Error while executing Python code.
Reading symbols from main...done.
Then I haved double checked my pretty printing installation directory. Under the directory /home/jerry/myLib/gdb_stl_support/python/libstdcxx/v6/, I can clearly see I have the printers.py file. And I also view the content of printers.py, I'm sure it also has the register_libstdcxx_printers class. Why the python interpreter is still complaining the printers module is missing? This seems really strange to me.
I just tried something myself, and luckily, now it's working. At least it can print out the map and vector content as expected. Here is what I did:
Since it's complaining that it can't find the printer.py module, then I think should probably I tell python interpreter where this file is located. So I first added this extra line to my ~/.gdbinit:
sys.path.append("/home/jerry/myLib/gdb_stl_support/python/libstdcxx/v6")
(After the line sys.path.insert(0, '/home/jerry/myLib/gdb_stl_support/python') )
Then running gdb again, I got the following error:
Traceback (most recent call last):
File "<string>", line 5, in <module>
File "/home/jerry/myLib/gdb_stl_support/python/libstdcxx/v6/printers.py", line 1247, in register_libstdcxx_printers
gdb.printing.register_pretty_printer(obj, libstdcxx_printer)
File "/usr/share/gdb/python/gdb/printing.py", line 146, in register_pretty_printer
printer.name)
RuntimeError: pretty-printer already registered: libstdc++-v6
/home/jerry/.gdbinit:7: Error in sourced command file:
Error while executing Python code.
Given the error information, I edited the ~/.gdbinit file and commented the line register_libstdcxx_printers (None).
And then after running gdb, it works.
But I'm still wondering if directory in sys.path is searched recursively? I mean in my mind, the python interpreter should work like this: once you have added one directory to sys.path, then the subdirectory under that directory will also get searched for a module file.

Python import module using command prompt

I have a code in Python 2.7 write using the IDLE PyCharm on Windows 7 OS. Running inside the IDLE i have no problem to import all modules. When i run with the command prompt of windows i get this error message:
C:\Users\samsung>C:\PythonScript\TOOL.py
Traceback (most recent call last):
File "C:\PythonScript\TOOL.py", line 5, in <module
>
import ogr
ImportError: No module named ogr
I can import this module with the IDLE without problem.

Categories

Resources