may be python error! - python

Hi
I'm not familiar with python, I just want to check something so I tried to run a .py code in linux so I wrote :
./waf wifi-olsr-flowmon --plot
which is a .py program after that whatever I want to run just see these error:
/home/bahar/Desktop/ns/ns-allinone-3.9/ns-allinone-3.9/ns-3.9/wscript: error: Traceback (most recent call last):
File "/home/bahar/Desktop/ns/ns-allinone-3.9/ns-allinone-3.9/ns-3.9/.waf-1.5.16-e6d03192b5ddfa5ef2c8d65308e48e42/wafadmin/Utils.py", line 197, in load_module
exec(compile(code,file_path,'exec'),module.__dict__)
File "/home/bahar/Desktop/ns/ns-allinone-3.9/ns-allinone-3.9/ns-3.9/wscript", line 32, in <module>
import cflags # override the build profiles from waf
ImportError: No module named cflags
I dont know what does it mean or why it happened, would you please tell me what is the problem .
may be I should add this note that even now that I don't want to run any .py code and just wana run .cc I can't do it and see this error always
Bests

It means that Python was unable to locate a module named cflags, but the code you're running tries to import it. Perhaps you need to set PYTHONPATH, or install the cflags module.
(Also, paragraphs are your friend.)

Related

Error installing pyflycapture2 on Windows

I am attempting to install this https://github.com/jordens/pyflycapture2 python binding on my Windows machine. The readme only has instructions on how to do it for Linux systems, but I imagine the library should still work.
I am able to run "python setup.py install" and it seems to successfully complete, but when I try to run "python test_flycapture2.py" I get this error:
C:\Users\clinic\Desktop\pyflycapture2>python test_flycapture2.py Traceback (most recent call last):
File "test_flycapture2.py", line 20, in <module>
import flycapture2 as fc2
File "build\bdist.win-amd64\egg\flycapture2.py", line 7, in <module>
File "build\bdist.win-amd64\egg\flycapture2.py", line 6, in __bootstrap__
ImportError: DLL load failed: The specified module could not be found.
This seems to imply that flycapture2 wasn't installed correctly. When I instead just open a python session and do "import flycapture2" I get the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "build\bdist.win-amd64\egg\flycapture2.py", line 7, in <module>
File "build\bdist.win-amd64\egg\flycapture2.py", line 6, in __bootstrap__
ImportError: DLL load failed: The specified module could not be found.
Have I done something wrong with the installation process or does pyflycapture2 just not work with Windows?
A dumb solution that's worth a try. There are chances that the DLL are searched directly from where you're starting the python script. So if you have the dll somewhere on your computer, copy it along where you have your test_flycapture2.py.
But given the fact that the setup.py file has a whole bunch of absolute paths in there, I would not place my hopes too high. You can also try to install FlyCapture 2 at the exact same path, run python setup.py bdist_wheel (you will need to install wheel first with pip) in the pyflycapture2 folder, and see if that succeeds.
If it does, try installing the generated wheel (that will be in dist/ subfolder) by doing pip install dist/pyfly....wheel and test again.
Hope this helps
I'm answering this mostly because I found another post where the same question had been posted but the original problem was never answered.
How do I run an installed Python module on Windows?
In the comments, the original poster says that it suddenly started working. I found that the solution was simply to restart my computer. I have now attempted this on two computers and this worked for both of them.

Python version conflict. Jhbuild not reading Jhbuildrc?

I was about to set up pygobject for gtk+3. This http://python-gtk-3-tutorial.readthedocs.org/en/latest/install.html#id2 page says I need Jhbuild. I went ahead and installed that. But, it gives me traceback
Traceback (most recent call last):
File "/usr/bin/jhbuild", line 6, in <module>
import __builtin__
ImportError: No module named '__builtin__'
Which obviously is due to wrong version of python(my default is python3).
So, I found this page https://wiki.gnome.org/Projects/Jhbuild/Dependencies/ArchLinux
Which suggests to add
os.environ['PYTHON'] = '/usr/bin/python2'
line to ~/.config/jhbuildrc which I did. When I run jhbuild again it spews the same traceback.
I tried putting the file as ~/.jhbuildrc. Doesn't work either.
So, I'm stuck here. Any help would be appreciated.
I'm on Arch Linux, fwiw.
You probably want to set PYTHON=/usr/bin/python2 when you ./autogen.sh --simple-install for jhbuild itself. The jhbuildrc file is only used for things it builds.
See also: https://wiki.archlinux.org/index.php/JHBuild

JPype won't compile properly

So I am having trouble compiling a very simple python script using JPype.
My code goes like:
from jpype import *
startJVM(getDefaultJVMPath(), "-ea")
java.lang.System.out.println("hello world")
shutdownJVM()
and when I run it I receive an error saying:
Traceback (most recent call last): File "test.py", line 2, in
<module>
startJVM(getDefaultJVMPath(), "-ea") File "/usr/lib/pymodules/python2.7/jpype/_core.py", line 44, in startJVM
_jpype.startup(jvm, tuple(args), True) RuntimeError: Unable to load DLL [/usr/java/jre1.5.0_05/lib/i386/client/libjvm.so], error =
/usr/java/jre1.5.0_05/lib/i386/client/libjvm.so: cannot open shared
object file: No such file or directory at
src/native/common/include/jp_platform_linux.h:45
I'm stuck and I really need help. Thanks!
I had the same problem
RuntimeError: Unable to load DLL [/usr/java/jre1.5.0_05/lib/i386/client/libjvm.so], error = /usr/java/jre1.5.0_05/lib/i386/client/libjvm.so: cannot open shared object file: No such file or directory at src/native/common/include/jp_platform_linux.h:45
In my case wrong JAVA_HOME path was set
/profile/etc
export JAVA_HOME
JAVA_HOME=/usr/lib/jvm/java-6-openjdk-amd64
PATH="$JAVA_HOME/bin:$PATH"
export PATH
The work around is to define the full path directly in the call to the JVM:
from jpype import *
startJVM('/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/MacOS/libjli.dylib', "-ea", "-Djava.class.path=/tmp/Jpype/sample")
java.lang.System.out.println("Hello World!!")
shutdownJVM()
Original text:
Similar issues when trying to run JPype on MacOS El Capitan. I could
not figure out how to coax the _darwin.py code finding the correct JVM
location, despite the JAVA_HOME system variable being set properly.
Caveat cursor, trying to run the above code in the Spyder IPython console did not produce any output, but the normal Console would.

Shared library _sqlite3.so not found when importing sqlite3 on Python 2.6.6

Okay i've been battling for this for 2 days, that usually means its something too simple to realize.
I have an embedded linux system which I cross compile on my ubuntu. When compiling python, sqlite3 is not on the list of modules that have not been able to be compiled.
But, the _sqlite3.so library is not in the same location as for example json.so and ctypes.so array.so...
in Python-2.6.6/build/lib.linux868-2.6/
The actual module with the init-functions etc is in the right place at :
in Python-2.6.6/modules and it can also be found on the target system.
Since the so-file was missing, i tried compiling it myself as a shared library using my arm-compiler. This did not work either.
Without manually compiled so-file:
>>> import sqlite3
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "rootfs/python/lib/python2.6/sqlite3/__init__.py", line 24, in <module>
File "rootfs/python/lib/python2.6/sqlite3/dbapi2.py", line 27, in <module>
ImportError: /python/lib/python2.6/lib-dynload/_sqlite3.so: cannot open shared object file: No such file or directory
With the compiled shared library found at lib-dynloads:
>>> import sqlite3
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "rootfs/python/lib/python2.6/sqlite3/__init__.py", line 24, in <module>
File "rootfs/python/lib/python2.6/sqlite3/dbapi2.py", line 27, in <module>
ImportError: dynamic module does not define init function (init_sqlite3)
Edit:
I was wondering if i had compiled the right library for sqlite3. As far as i now understand the _sqlite3.so is something the python builder makes and libsqlite3.so is the library it needs to build it? And libsqlite3.so is build from Sqlite3-source code. Am i mistaken here?
Anyone with more embedded Linux or Python experience have an idea what I am doing wrong here?
Try to compile and install sqlite3 first on your system, and compiler python later. Or just
easy_install pysqlite
Ok, figured this out. Somehow I did not manually compile the SO-file correctly. Got this to work like so:
First from setup.py , I added verbose debugging enabled for sqlite3 module. This added a printout that solved the problem:
skipping incompatible /usr/lib/libsqlite3.so
cannot find -sqlite3
That made me realize that the setup.py had chosen the first path where it found any module named sqlite3, ignoring it's architecture alltogether. Removing other search paths from the setup.py, but the one i had the ARM compiled library in, made it work. The _sqlite3.so was compiled nicely with all the other modules.

Workaround read-only site-packages for cx_freeze

I'm currently trying to make cx_freeze to work on a Solaris workstation I have to work with, in order to make an executable from a Python script I have. Problem is, I'm not administrator of this machine, and installation of cx_freeze requests write to site-packages, which is read-only for me.
So, obviously, I get this error:
creating /usr/local/lib/python2.6/site-packages/cx_Freeze
error: could not create '/usr/local/lib/python2.6/site-packages/cx_Freeze': Read-only file system
And if I try to run it anyway, it fails:
bash-3.00$ python /home/xxxx/cx_freeze-4.2.3/cxfreeze --target-dir cx_dist src/p_tool.py
Traceback (most recent call last):
File "/home/xxxx/cx_freeze-4.2.3/cxfreeze", line 5, in <module>
main()
File "/home/xxxx/cx_freeze-4.2.3/cx_Freeze/main.py", line 187, in main
silent = options.silent)
File "/home/xxxx/cx_freeze-4.2.3/cx_Freeze/freezer.py", line 91, in __init__
self._VerifyConfiguration()
File "/home/xxxx/cx_freeze-4.2.3/cx_Freeze/freezer.py", line 371, in _VerifyConfiguration
self._GetInitScriptFileName()
File "/home/xxxx/cx_freeze-4.2.3/cx_Freeze/freezer.py", line 283, in _GetInitScriptFileName
raise ConfigError("no initscript named %s", name)
cx_Freeze.freezer.ConfigError: no initscript named Console
Obviously, this is linked to the failed installation. So, here's my question:
Without installation of virtualenv, could I avoid the writing to site-packages, and make cx_freeze to execute from my home folder?
EDIT I had a look at site.py documentation, and PYTHONPATH filling should be equivalent to use of site-packages. So my question is now more something like: what is the path to be added to PYTHONPATH, so that cx_freeze could be executed from any location?
Notes:
I would like to avoid to deal with virtualenv, as I'm already struggling to understand the executable tools...
I saw this question, but this still requires access to site-packages folder, plus it's not user-specific;
I tried adding the following path to PYTHONPATH, but this does not work: /home/xxxx/cx_freeze-4.2.3/build/lib.solaris-2.10-sun4v-2.6;
I'm also trying to use PyInstaller but have dependency problems (and the administrator is not really helping me).
This works like a charm for me :
$ python setup.py install --home=$HOME
Run in the source directory of cx_freeze found on the Sourceforge download page.

Categories

Resources