Is anyone able to get pyAA working with py2exe? pyAA can be downloaded here.
I have trying to do this for the last 2 days and I am unable to reach a solution till now. The example files are like given below:
hello.py
import pyAA
print "Hello, World"
setup.py
from distutils.core import setup
import py2exe
setup(console=['hello.py'],
options = {"py2exe": {"bundle_files": 1}})
Now, if we run:
python setup.py py2exe
the executable is created. But running it gives the following error:
Traceback (most recent call last):
File "hello.py", line 1, in ?
File "zipextimporter.pyc", line 82, in load_module
File "pyAA\__init__.pyc", line 1, in ?
File "zipextimporter.pyc", line 82, in load_module
File "pyAA\AA.pyc", line 8, in ?
File "zipextimporter.pyc", line 82, in load_module
File "pyAA\pyAAc.pyc", line 5, in ?
File "zipextimporter.pyc", line 98, in load_module
ImportError: MemoryLoadLibrary failed loading pyAA\_pyAAc.pyd
I tried using dependency walker but I was unable to make too much sense of the same. I tried to add/delete some DLLs but to no avail.
p.s -> Please note that without bundle_files, it is working perfectly. But one of the requirements of the projects mean that bundle_file is required.
This king of thing seems to be a common problem with py2exe. Maybe try using another installer such as PyInstaller.
When I install pyAA and run depends on _pyAAc.pyd, it tells me I'm missing IESHIMS.DLL, though that might be because I'm on Windows 7.
_pyAAc.pyd is a DLL, I think those have to be loaded directly from the file system (not from memory buffers or archives).
If a one-file-solution is needed you could do your own bundling of the working unbundled py2exe result that unpacks itself to TEMP and runs from there. I suspect some self extracting archive maker could do this trick for you without the need for any coding on your part.
Having fought with Py2Exe a few times myself, bundling DLLs with dependencies usually causes headaches. If my memory serves me correctly, try adding sys.exec_prefix to PATH environment variable. This should allow the program to find the IESHIMS.DLL
os.environ['PATH'] = os.sep.join([sys.exec_prefix, os.environ['PATH']])
Related
I'm trying to run a Python script that involves ARP sniffing and is apparently dependent on the Scapy library being present. I have absolutely no idea what I'm doing but I'm reasonably good at Googling, following directions, and copying/pasting. I have it up and running on my Mac, but I'm stuck on what I hope is the last hurdle in getting Scapy working on my Windows computer (which is ultimately the one that needs to be running this script).
I followed all of the instructions at http://www.secdev.org/projects/scapy/doc/installation.html#windows, except that I chose Python 2.7 and used the newer 2.7-compatible versions of everything listed there. I used “python setup.py install” (successfully, as best I could tell) on all installs except Pypcap and Libdnet, which I installed via the Exe as an Administrator as instructed.
Unfortunately, when I type "scapy" into the command prompt to test if it works, I get the following information & error message:
C:\scapy-2.3.1>scapy
INFO: Can't import python gnuplot wrapper . Won't be able to plot.
INFO: Can't import PyX. Won't be able to use psdump() or pdfdump().
Traceback (most recent call last):
File "C:\Python27\Scripts\\scapy", line 25, in <module>
interact()
File "C:\Python27\lib\site-packages\scapy\main.py", line 278, in interact
scapy_builtins = __import__("all",globals(),locals(),".").__dict__
File "C:\Python27\lib\site-packages\scapy\all.py", line 16, in <module>
from arch import *
File "C:\Python27\lib\site-packages\scapy\arch\__init__.py", line 79, in <module>
from windows import *
File "C:\Python27\lib\site-packages\scapy\arch\windows\__init__.py", line 214, in <module>
ifaces.load_from_dnet()
File "C:\Python27\lib\site-packages\scapy\arch\windows\__init__.py", line 173, in load_from_dnet
self.data[i["name"]] = NetworkInterface(i)
File "C:\Python27\lib\site-packages\scapy\arch\windows\__init__.py", line 93, in __init__
self.update(dnetdict)
File "C:\Python27\lib\site-packages\scapy\arch\windows\__init__.py", line 107, in update
self._update_pcapdata()
File "C:\Python27\lib\site-packages\scapy\arch\windows\__init__.py", line 118, in _update_pcapdata
win_name = pcapdnet.pcap.ex_name(guess)
AttributeError: 'module' object has no attribute 'ex_name'
Can anyone help me out? If you need more information please let me know.
I am running Windows 10.
Thanks in advance,
- Ethan
I had same problem.
To solve it, i downloaded dnet-1.12.win32-py2.7.exe
and pcap-1.1.win32-py2.7.exe.
You might want to try with Scapy's current development version (from the Github repository). Support for Windows has been updated recently and should work without the need of Libdnet.
If that's not the case, you should probably open an issue.
Try it with scapy3k. Install python3 (e.g. I use Anaconda 3.5), and WinPcap driver. You do not need dnet or pypcap. Install using pip install scapy-python3 or from http://github.com/phaethon/scapy
I get a warning message while trying to create exectable file using pyinstaller. This warning appeared after installing Pillow. Previously i nevre got any warnings and was able to make it through.
the warning i get by pyinstaller is:
7314 INFO: Analyzing main.py
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/PyInstaller-2.1.1dev_-py2.7.egg/PyInstaller/hooks/hook-PIL.Image.py:14: RuntimeWarning: Parent module 'PyInstaller.hooks.hook-PIL' not found while handling absolute import
from PyInstaller.hooks.shared_PIL_Image import *
Also when i tried to run the executable's exe/consol version of my code that lies inside the dist folder created by the pyinstaller (dist/main/main), these are displayed..
Traceback (most recent call last):
File "<string>", line 26, in <module>
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/PyInstaller-2.1.1dev_-py2.7.egg/PyInstaller/loader/pyi_importers.py", line 276, in load_module
exec(bytecode, module.__dict__)
File "/Users/..../build/main/out00-PYZ.pyz/PIL.PngImagePlugin", line 40, in <module>
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/PyInstaller-2.1.1dev_-py2.7.egg/PyInstaller/loader/pyi_importers.py", line 276, in load_module
exec(bytecode, module.__dict__)
File "/Users/..../build/main/out00-PYZ.pyz/PIL.Image", line 53, in <module>
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/PyInstaller-2.1.1dev_-py2.7.egg/PyInstaller/loader/pyi_importers.py", line 276, in load_module
exec(bytecode, module.__dict__)
File "/Users/..../build/main/out00-PYZ.pyz/FixTk", line 74, in <module>
OSError: [Errno 20] Not a directory: '/Users/.../dist/main/tcl'
logout
[Process completed]
so, i tried by uninstalling pillow, installing tk tcl dev version. And then installed pillow. Even that didnt helped.
I also tried reinstalling pyinstaller,. didnt help too
Update 1:
It seems Pyinstaller.hooks.hook-PIL.py file was missing in the Pyinstaller/hooks directory. And it was missing on all platforms(Mac, windows and linux). This is the warning/error message that i get on windows, which is the same i got on mac and on linux.
Later i found a link which said, its just to need Python import machinery happy. so i created as said so. Then i dont get the same error on all platforms, But on mac i still get the PILImagePlugin,Image and FixTk errors
Solution for tcl:
I found what was going wrong,.. Every problem that i faced on OSX was the OS itself(exactly the macport). Python by default comes with the mac OS. And this version of python may be useful for just learning basic python, but is not suitable for Development purpose.
Installing brew's python helped. I followed this SO link. After doing these i was still getting errors. Later i had to change the paths on /etc/paths. Basically rearranging them should work. But still then i wasn't getting it right.
Then i had to change the .bash_profile, which worked for most users, But still i was getting mac's version of python and pip, not the brews version of python.
Finally i had to restart the machine for a couple of times and do the /etc/paths and .bash_profile steps repeatedly to get the system wide effect to accept brews version of python and pip
Solution for PIL:
just adding a file called hook-PIL.py with an empty content would serve the purpose. I found a link which was having the hook files content of pyinstaller.
The location to create
for mac : /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/PyInstaller-2.1.1dev_-py2.7.egg/PyInstaller/hooks/ Actually for mac this step wouldn’t be required. When we install python through brew and change the path, everything that you try to install later either through pip install or from source packages tend to choose a different path. And everything will be taken care of.
for windows:C:\Python27\lib\site-packages\PyInstaller-2.1.1.dev0-py2.7.egg\PyInstaller\hooks
**Please check if this is a valid path on your machine before creating the file and then create the file. And im not sure or i don't know if just adding an empty file is the right way. But it worked for me
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.
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.)
I recently installed the hg tip version of Ropemacs and I'd like to use it when editing remote files using TRAMP. Has anyone done this? When I try to use M-/ to complete a variable name, I am asked to enter the Rope project root folder and I enter: /ssh:myhost:/path/to/myproject/ and it gives me the following error:
Opening [/ssh:myhost:/path/to/myproject/] project ...
pymacs-report-error: Python: Traceback (most recent call last):
File "/home/saltycrane/lib/python-environments/default/lib/python2.6/site-packages/Pymacs/pymacs.py", line 147, in loop
value = eval(text)
File "<string>", line 1, in <module>
File "/home/saltycrane/lib/python-environments/default/lib/python2.6/site-packages/ropemode/decorators.py", line 53, in newfunc
return func(*args, **kwds)
File "/home/saltycrane/lib/python-environments/default/lib/python2.6/site-packages/ropemode/interface.py", line 254, in code_assist
_CodeAssist(self, self.env).code_assist(prefix)
File "/home/saltycrane/lib/python-environments/default/lib/python2.6/site-packages/ropemode/interface.py", line 538, in code_assist
proposals = self._calculate_proposals()
File "/home/saltycrane/lib/python-environments/default/lib/python2.6/site-packages/ropemode/interface.py", line 597, in _calculate_proposals
self.interface._check_project()
File "/home/saltycrane/lib/python-environments/default/lib/python2.6/site-packages/ropemode/interface.py", line 448, in _check_project
self.open_project()
File "/home/saltycrane/lib/python-environments/default/lib/python2.6/site-packages/ropemode/decorators.py", line 53, in newfunc
return func(*args, **kwds)
File "/home/saltycrane/lib/python-environments/default/lib/python2.6/site-packages/ropemode/interface.py", line 88, in open_project
self.project = rope.base.project.Project(root)
File "/home/saltycrane/lib/python-environments/default/lib/python2.6/site-packages/rope/base/project.py", line 134, in __init__
os.mkdir(self._address)
OSError: [Errno 2] No such file or directory: '/ssh:myhost:/path/to/myproject'
I imagine ropemacs doesn't support remote files with TRAMP. Just wondering if anyone has found a workaround. Maybe some custom elisp? Or maybe I should use sshfs and mount the remote filesystem locally...
I installed ropemacs in a virtualenv located at /home/saltycrane/lib/python-environments/default. I am using GNU Emacs 23.1.50.1 on Ubuntu Lucid.
I should mention that completion with M-/ works fine when I'm not using TRAMP.
No, this is not possible using TRAMP, because the Python rope library does not make calls back into Emacs when it wants to scan the filesystem for Python files to find their classes and functions — instead, it uses calls like listdir() and open() on the filesystem directly, without giving Emacs a chance to get in the way and intercept the special TRAMP-prefixed paths that you are editing.
Using sshfs might be possible, as the comments have mentioned, but for rope I imagine that it would be a very slow solution, since rope has to open so many files to find out the state of your project.
I generally leave rope off, or else figure out how to export an Emacs session from the remote system, when editing across a remote-filesystem link. I wonder if you could use something like rsync or dropbox or even a DVCS so that the files would be present on your local hard drive as immediately-accessible copies, but so that changes you save would get copied across?