I am trying to install a python library and receive this error after downloading an egg file.
Downloading http://pypi.python.org/packages/2.5/s/setuptools/setuptools-0.6c7-py2.5.egg
Traceback (most recent call last):
File "setup.py", line 10, in <module>
use_setuptools(min_version=min_version)
File "/Users/tylo/Downloads/Archives/simplejson-2.0.9/ez_setup.py", line 88, in use_setuptools
import setuptools; setuptools.bootstrap_install_from = egg
zipimport.ZipImportError: can't decompress data; zlib not available
I did some research and discovered that zlib is built into OS X.
What could be going wrong here?
Run xcode-select --install to fix installation of Command Line Tools for Xcode working.
It's not the zlib C library that is missing, but the zlib Python module. This is usually caused by compiling Python yourself, and not having the necessary bits (header files, specifically) of zlib available, even when you do have the C library available. Or, sometimes, by the zlib Python module having the wrong permissions; take a look in the directories in sys.path, looking for a zlib.so or zlibmodule.so. If it doesn't exist, the Python installation was built without it, or building it failed. If it does exist, check its permissions (and the directory's permissions.)
Related
I am trying to convert some Python code into an .exe with PyInstaller. My code uses distutils, which has already caused me some head scratching in the past as it seems to duplicate setuptools functionality, and interacts with it strangely. It e.g. requires an unused import of setuptools to work properly which seems very unpythonic to me.
I need to use both packages inside my project. I import both packages in the order import setuptools; import distutils because the other order throws a warning which is already worrying.
My script runs fine but after I turn it into an exe I get a traceback inside of the suspicious _distutils_hack submodule of setuptools. And yes it just prints a file name with no context.
Traceback (most recent call last):
<18 lines omitted>
File "PyInstaller\loader\pyimod03_importers.py", line 495, in exec_module
File "_distutils_hack\override.py", line 71, in <module>
File "_distutils_hack\__init__.py", line 71, in do_override
File "_distutils_hack\__init__.py", line 59, in ensure_local_distutils
AssertionError: C:\Users\<omitted>\AppData\Local\Temp\_MEI294562\distutils\core.pyc
I am using
Python 3.7.7 on win32 (but I reproduced it with 3.8, 3.9, and 3.10)
pyinstaller==4.8 (Jan 2022) for Windows
distutils==3.7.7 (built-in)
setuptools==60.5.0 (Jan 2022)
Apparently, setuptools is listed on PyPI and thus upgradable, but distutils is not listed on PyPI and thus not upgradable (the version is bundled with Python).
A workaround I found was downgrading to
pip install setuptools==59.8.0
I reported this issue to the project and then confirmed the bug was introduced in setuptools==60.0.0. I'll update this question when I find out more, or it gets fixed.
I reported my issue to the setuptools project, but then the PyInstaller project stepped in to include a workaround on their side. Now any release starting from 5.4 should work! 👍
pip install pyinstaller>=5.4
Could someone please advise in resolving the below error?
Python 3.5.1 / jpype1-py3 0.5.5.2 installed on 64 bit windows machine.
I've cannot find _jtype anywhere in Lib or Lib/site-packages.
Regards
Steve
>>> import jpype
Traceback (most recent call last):
File "", line 1, in
import jpype
File "C:\Program Files\Python35\lib\site-packages\jpype\__init__.py", line 18, in
from ._jpackage import *
File "C:\Program Files\Python35\lib\site-packages\jpype\_jpackage.py", line 18, in
import _jpype
ImportError: DLL load failed: The specified module could not be found.
According to this thread, you need to make sure setup.py is pointing to the correct jvm directory. looking into setup.py of you can see that it searches for JAVA_HOME system variable:
java_home = os.getenv('JAVA_HOME', '')
found_jni = False
if os.path.exists(java_home):
platform_specific['include_dirs'] += [os.path.join(java_home, 'include')]
# The code goes on
It may be that you didn't configure this system variable.
Since you installed via pip, and probalby didn't touch te setup.py file, I recommend you to do the following:
1-) Uninstall the package, and delete the build directories
2-) Set JAVA_HOME variable following this
3-) Download JPype manually from github and install it using python setup.py install
Good luck, tell me if it works
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import pygame
File "C:\Program Files (x86)\Python35-32\lib\site-packages\pygame\__init__.py", line 127, in <module>
from pygame.base import *
ImportError: DLL load failed: The specified module could not be found.
Ensure that the version of PyGame you're using matches the version of Python you're using!
You have not installed Pygame correctly or not in the correct directory/file. What python version do you use and is your computer 32/64 bit?
Thx
This is a late answer, but may be it helps someone.
The pygame binary you use should be built for the Python version you have in your system.
In your case, you seem to have 32-bit Python3.5.
There is no official pygame binary for Python3.5 yet. But unofficial binaries are available here.
Download pygame-1.9.2b1-cp35-cp35m-win32.whl from the link (this is the 32-bit version for 32-bit Python3.5), and install it using pip.
Example: cd to the folder where you downloaded the .whl file, and run C:\Program Files (x86)\Python35-32\Scripts\pip install pygame-1.9.2b1-cp35-cp35m-win32.whl
Note:
pip may not play well when the python install directory has spaces. So please install python in a path without spaces. For example, C:\Python35-32 instead of C:\Program Files (x86)\Python35-32.
Also, see this answer in case you need more info on installing .whl files.
I downloaded fiona today. when I try to import it in Python using 'import fiona', I get the following error:
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import fiona
File "C:\Python27\lib\site-packages\fiona\__init__.py", line 72, in <module>
from fiona.collection import Collection, supported_drivers, vsi_path
File "C:\Python27\lib\site-packages\fiona\collection.py", line 7, in <module>
from fiona.ogrext import Iterator, ItemsIterator, KeysIterator
ImportError: No module named ogrext
I checked in my site-packages folder, and ogrext is a "C" file. I tried commenting out the import to see if it wasn't necessary, but this of course threw another error.
Specifically, how do I resolve this import error?
More generally, how does one resolve errors involving importing C files into a python library?
You can't just install any module by copying all the files to site-packages. Some modules are pure Python, but there are many with extensions written in other languages (C, C++, Fortran, etc.) that need to be compiled and linked into libraries before being used, and fiona is one of them. This compilation can be done at several stages - by the author, before distributing the module as a wheel, during the pip install process, or by downloading the package's source, unzipping/tarring it, and running python setup.py install. Unfortunately, Windows doesn't come with a compiler by default, so you either need to install and configure your system for gcc or Visual Studio, or use another method, such as a precompiled installer. Fortunately, fiona is available from Christoph Gohlke's Python Extension Packages for Windows Repository here. Download the installer for your version and bit-ness of Python, delete the fiona folder in site-packages, then run the installer. This site contains a large number of packages for scientific computing, and is my go-to resource when I need to install a new module, especially if it has extensions.
EDIT
Upon further inspection, it appears that fiona also requires the GDAL module, as well as six, both of which can be downloaded from Gohlke's repository. I first installed fiona only (I already had six installed), and got a missing DLL error. I then installed GDAL, and import fiona worked just fine - I'm not familiar with the module, so I didn't do any further testing, but hopefully everything should work now.
I am, like many others, trying to get MySQLdb for Python to run on Mac Snow Leopard (10.6.x) and I've been able to install the 64-bit MySQL DMG as recommended by various blogs/forum posts, and I've been able to install the setuptools and MySQLDB itself by using the
ARCHFLAGS='-arch 86_64' python2.7 setup.py clean
ARCHFLAGS='-arch 86_64' python2.7 setup.py build
sudo ARCHFLAGS='-arch 86_64' python2.7 setup.py install
As you can see from the above I have upgraded to Python 2.7 and everything seems fine; except when I try to import MySQLdb into python shell.
>>> import MySQLdb
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "build/bdist.macosx-10.6-universal/egg/MySQLdb/__init__.py", line 19, in <module>
File "build/bdist.macosx-10.6-universal/egg/_mysql.py", line 7, in <module>
File "build/bdist.macosx-10.6-universal/egg/_mysql.py", line 6, in __bootstrap__
ImportError: dlopen(/Users/ad/.python-eggs/MySQL_python-1.2.3c1-py2.6-macosx-10.6-universal.egg-tmp/_mysql.so, 2): Library not loaded: /usr/local/mysql/lib/libmysqlclient.16.dylib
Referenced from: /Users/ad/.python-eggs/MySQL_python-1.2.3c1-py2.6-macosx-10.6-universal.egg-tmp/_mysql.so
Reason: Incompatible library version: _mysql.so requires version 17.0.0 or later, but libmysqlclient.16.dylib provides version 16.0.0
I did a search and found libmysqlclient.16.dylib but not libmysqlclient.17.dylib
What is causing this problem, how do I resolve it, and even though I did a search for libmysqlclient.17.dylib there seems to be nothing about it; does it exist?
Thanks
You built the module against MySQL 5.5.x, but only the client libraries for 5.1.x are available on the system. Either install updated libraries, or build against an older version.
Definitely make sure that Python and MySQL are for the same architecture. You have to consistently use either 32bit or 64bit versions for both.
Also make sure that MySQLdb can find the MySQL libraries and includes, but from your error message it seems like this is the case.