record extension file missing in Xlib - python

I tried running a linux keylogger called pykeylogger but ran into the following error:
"...from Xlib.ext import record
ImportError: cannot import name record"
I went into the ext directory of Xlib and saw there is no record.py in there. Is there somewhere I can get this file? Also, is there a reason it wouldn't have been installed with the rest of Xlib? I downloaded Xlib from here:
http://python-xlib.sourceforge.net/

Related

Pyinstaller to package app hidden-import warning/exceptions

So, I've had some trouble setting up my application through Inno setup Compiler, at first I assumed it was a problem within Inno itself but on further inspection I think it is my actual exe. I am able to create a working exe file that runs my program properly but only on my own pc. I am able to create the setup file that also works through Inno setup but it only works on my own pc. I have sent both the actual exe file and the Inno setup file to another computer and downloaded it there and ran it, both meet the same "Fatal Error: failed to run script tk_app.py". Therefore, the problem must be that I have not been able to pavkage the app properly with pyinstaller.
My prgoram has 5 files in total (all in the same folder): main.py, file1.py, file2.py file3.py, tk_app.py
All of them importing each other and using python libraries. I know that pyinstaller supports librarires such as pandas, tkinter and many more without needing the --hidden-impoort= command and that it will pick up all files within the program if there are files that are importing each other.
So I use the file tk_app.py (which contains my tkinter UI and imports main.py which then goes onto import file1.py which import another file so on)
The pyinstaller command line I use to make the exe is as follows:
PS C:\Users\ripta\Desktop\CODING\CSV_Upload> pyinstaller -w --hidden-import=bs4 --hidden-import=fake_useragent --hidden-import=urllib.prase --hidden-import=urllib.request --hidden-import=os --hidden-import=pandas.io.parsers --icon=trademark_icon.ico --onefile tk_app.py
My question is, will pyinstaller tell me when it needs a given --hidden-import='name' when running becuase it doesn not throw up any errors and does produce a spec file, a build folder and a dist folder containing the exe file.
I have noticed that it throws up WARNINGs or Exceptions (also not sure why it mentions django as I do not import or use it at all inthe application) :
59182 INFO: Loading module hook 'hook-django.db.backends.py' from 'c:\\users\\ripta\\appdata\\local\\programs\\python\\python36-32\\lib\\site-packages\\PyInstaller\\hooks'... 61711 WARNING: Hidden import "django.db.backends.__pycache__.base" not found! 61712 INFO: Loading module hook 'hook-django.py' from 'c:\\users\\ripta\\appdata\\local\\programs\\python\\python36-32\\lib\\site-packages\\PyInstaller\\hooks'... Traceback (most recent call last): File "<string>", line 21, in walk_packages File "c:\users\ripta\appdata\local\programs\python\python36-32\lib\site-packages\django\contrib\gis\admin\__init__.py", line 5, in <module>
Or show Hidden-import not found (Of imports I have no idea about):
149329 WARNING: Hidden import "pkg_resources.py2_warn" not found! 149330 WARNING: Hidden import "pkg_resources.markers" not found!
The fact that the script fails to run on any other computer besided my own leads me to think that it must be lacking a dependency that is only found on my computer, therefore I am not using pyinstaller correctly but am not too sure where exactly I am making the mistake.
First I've uninstalled Setuptools and reinstalled it with specific version. Then, I've imported pkg_resources.py2_warn as hidden import :
pip uninstalled setuptools
pip install --upgrade 'setuptools<45.0.0'
pyinstaller --hidden-import='pkg_resources.py2_warn' tk_app.py
It worked for me.

Py2exe; Import Error no module named Tweepy

My python script includes a Qt GUI which I'm trying to convert into a Windows executable using Py2exe. My script is using the Tweepy module to fetch data from Twitter. So I include Tweepy and try to compile it into an executable using the following Setup.py:
from distutils.core import setup
import py2exe
setup(
windows = [{"script": "main.py"}],
options = {"py2exe":{"includes":["sip", "tweepy"]}}
)
The following Error gets raised:
raise ImportError, "No module named " + qname
ImportError: No module named tweepy
I've succesfully used the same setup file (minus the 'Tweepy include') to compile other script in the past. What am I missing here?
Assuming that you have tweepy installed in the python installation that you are trying to build with try adding:
import tweepy
near the start of your setup.py to ensure that py2exe can really see it, some packages do some interesting things during import.

Creating and using of procname.so

I would like to edit the process name of my python scripts by the use of http://code.google.com/p/procname/
I downloaded the source file of procname, extracted the content into my script directory and changed the makefile to:
PYTHON?=python3
TESTFLAGS=-p -v
TESTOPTS=
SETUPFLAGS=
GCC=gcc
VER=3.1
DESTDIR=.
Then I did make and procname.so was created in the same directory where my script is.
In the script I added import procname and tried to edit the process name by procname.setprocname('test_name.py').
Now i get an error:
import procname
ImportError: /path/to/script_directory/procname.so: undefined symbol: Py_InitModule3
The procname extension module does not work in Python 3. procnamemodule.c uses Py_InitModule3, which no longer exists in Python 3.

Importing PyVISA via Py2exe

My script file test.py is:
try:
from visa import *
except Exception as ex:
print ex
raw_input()
My setup.py file is:
from distutils.core import setup
import py2exe
setup(console=['test.py'])
I then run:
python setup.py py2exe
If I then launch test.exe on my pc I see no issues but if I copy it to a new pc with no prior python installs I get:
[Error 126] The specified module could not be found
I don't know how to get the full traceback to print. Has anyone else seen this issue?
Running Python 2.7, PyVisa 1.4. Both machines are Win7.
Turns out the problem was that the visa libraries that pyvisa relies on weren't installed on the test pc. These libraries don't come included with pyvisa.

import modules in python

when i write import win32print in my python command line (IDLE) it works fine and it is imported...
but when i write import win32print in my py file then it gives an error
says no module named win32print
why am i not able to load the module when writing the same statement in a py script...im using windows XP
Check if you are running on the same installation. I'd do that by looking the path:
import sys
print sys.path
And compare the output on IDLE and when you run the .py

Categories