I can use the module correctly by Python, but when using Jython, some error occurs...
Code:
from jieba import *
Errors:
Traceback (most recent call last):
File "/Users/Jack/Documents/workspace/FirstJython/hellojyphon.py", line 8, in <module>
from jieba import *
File "/Users/Jack/Documents/workspace/FirstJython/jieba/__init__.py", line 15, in <module>
from ._compat import *
ImportError: No module named _compat
Is there any differences between Python and Jython when import?
I solve it by myself.
There is something wrong when using relative directories in Jython.
so after I change ._compat to jieba._compat, the problem solved!
But I don't exactly know the reason...
Related
I have a python program to which I am adding GPIO pin control functionality. It is a multi-threaded system that runs fine until I try to do an "import RPi.GPIO as GPIO". Then I get the error below:
Traceback (most recent call last):
File "/usr/local/System/main.py", line 20, in <module>
from LightUpAlarm import AlarmCli
File "/usr/local/System/LightUpAlarm/AlarmCli.py", line 26, in <module>
from AlarmManager import AlarmManager
ImportError: No module named AlarmManager
The module "AlarmManager" was available until I tried to import "RPi.GPIO". I would appreciate any help understanding what I am doing wrong. Thanks in advance.
Pastebin link to full python file generating error. AlarmThread.py
I've installed igraph form .whl file using pip install. When I was trying to test the correctness of installation
import igraph.test
igraph.test.test()
I got this error:
Traceback (most recent call last):
File "D:/Nauka/Praca-inzynierska/Barabasi-Albert.py", line 4, in <module>
import igraph.test
File "D:\Programy\Python 3.5\lib\site-packages\igraph\__init__.py", line 34, in <module>
from igraph._igraph import *
ImportError: No module named 'igraph._igraph'
(the same error pops out if I'm trying to import igraph not igraph.test).
I've tried adding path (I don't know if this is rigth):
import sys
sys.path.append ("D:/Programy/Python 3.5/Lib/site-packages/igraph")
but it didn't work.
One thing I discovered is that if I delete "__init__" file from igraph folder I can import igraph without error, but it doesn't work for igraph.test.
If it's relevant I have Python 2.7 installed on my machine alongside Python 3.5.
Thank you in advance for any help.
I installed a module one month ago. At that time, I could import the module successfully.
Now, when I import this module, there is an ImportError,
>>> import anuga
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/lili/anuga_core/source/anuga/__init__.py", line 110, in <module> from anuga.file_conversion.urs2nc import urs2nc
File "/home/lili/anuga_core/source/anuga/file_conversion/urs2nc.py", line 12, in <module>
from mux import WAVEHEIGHT_MUX_LABEL, EAST_VELOCITY_LABEL, \
ImportError: No module named mux
How could I solve this problem?
ImportError comes only when the module is not available in the list called sys.path. Since the current operating system is Linux based (I got an idea from the error message /home/lili), it is required to have mux.py in the path (i.e, sys.path). The mux.py file will be exactly similar to the file available in this link.
`https://anuga.anu.edu.au/svn/anuga/trunk/anuga_core/source/anuga/file/mux.py`
All these problems come when the installation of ANUGA is not proper.
as from title, if I try to import ctypes in nuke6.1v2 I get this error:
import ctypes
# Result: Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Program Files\Nuke6.1v2\lib\ctypes\__init__.py", line 10, in <module>
from _ctypes import Union, Structure, Array
ImportError: No module named _ctypes
I also tryed to import it from the Python 2.6 main folder but with no luck.
However, if I try to import it in another package (softimage for example) I have no problem at all.
I have found a lot of people having the same problem, but none of the solutions worked for me.
Any idea?
Thanks
I am encountering these errors frequently when I install python libraries and I'm wondering what I am doing wrong
the current example is the libchromaprint library
http://acoustid.org/chromaprint
I install it and everything, try to run the python example, get:
Traceback (most recent call last):
File "examples/fpwav.py", line 7, in <module>
import chromaprint
File "build/bdist.linux-x86_64/egg/chromaprint/__init__.py", line 24, in <module>
ImportError: couldn't find libchromaprint
and then when I check:
find /usr/local/lib/libch*
/usr/local/lib/libchromaprint.so
/usr/local/lib/libchromaprint.so.0
/usr/local/lib/libchromaprint.so.0.1.3
what am I doing wrong?
Python does not use your usual library path. The chromaprint you're looking for should be somewhere like /usr/lib/pymodules/python2.6.
From the python interpreter do:
>>> import sys
>>> sys.path
This will show you the directories python searches for a module.