Closed SelaO closed 6 years ago
It needs libarchive to be available and in-scope.
How can it be in scope when I do pip install libarchive
in powershell? (not python interpreter in the console)
libarchive, the C library (not the Python package).
I need to build that on my own on widows? and even though they mention an sln file for VS there's no sln.
I can't just sudo apt-install on windows and I'm not going to mess with cmake and gcc now.
Do you know if there is a simple way to make it available on windows?
Hi Dustin,
Thank you for making this Python package.
I have installed a fair number of Python packages, and this is the first one that seems intended for people with so much software expertise. I am not complaining, I simply want to tell you what this package is like for someone like me. I'm not a software engineer. I did not understand that to get libarchive the Python package to run on Windows, I needed to compile a C library with the same name, though I might have guessed that, since readme says to run "apt-get install libarchive-dev" on linux.
I do not have gcc installed on Windows, and I have only installed and run it a dozen times on Linux and Solaris. With 4-8 hours, I think I could install it with cygwin or some other environment and manage to compile libarchive. It is not worth the effort for me, so I used zip files and the Python zipfile package.
It would be helpful to people with my kind of background if you include in the readme a statement that on Windows, you'll have to download the libarchive C library from libarchive.org, and compile it.
I have seen comments that there is a need for a Python package for interacting with 7-zip files. If you spent the time to do one of three things, a lot of people would notice and appreciate you:
1) In the code here, include the libarchive C binaries for Windows, Linux, and Mac, and include instructions for installing them, if installing them from your copies of the binaries is possible. 2) Include in this package the proper libarchive C binaries, at the cost of space and download time, and have pip install them. 3) Use the libarchive C code to create a C extension for Python (I know, lots of work).
Thank you, David
I came across this.. http://gnuwin32.sourceforge.net/packages/libarchive.htm
But I'm lost on how to use them in Python as I'm new to Python.
Python is a multi-platform programming language and as such libraries should also adhere to this concept. This library unfortunately does not work on most computers because it cannot find the libraries on Windows.
I will now explain how to compile libarchive.dll, so that one can install this python libarchive package.
Get the x64 installer from https://www.msys2.org/ and run it.
Go to the installation folder and run mingw64.exe
.
Run pacman -Syu
, restart the shell and run pacman -Su
.
Install minGW-64 via pacman -S mingw-w64-x86_64-toolchain
.
Install minGW-64-cmake (not normal cmake, as this will lack minGW generators) via pacman -S mingw-w64-x86_64-cmake
.
Install libxml2 via pacman -S mingw-w64-x86_64-libxml2
.
Restart the shell.
Download and extract the libarchive source: https://github.com/libarchive/libarchive/releases
In the msys2 shell navigate to the extraced folder. You can access Windows paths via cd /c/folder/subfolder
for c:\folder\subfolder
.
Create makefiles via cmake . -G "MinGW Makefiles"
. You might have to run this twice, as the first time you might get an error about sh.exe.
Compile via mingw32-make.exe
.
libarchive.dll
is now in <libarchive_source\bin\libarchive.dll
.
In order to use this .dll you also need other dlls from the <msys2>\mingw64\bin
folder. Copy those .dlls to the libarchive.dll folder:
libbz2-1.dll
libexpat-1.dll
libiconv-2.dll
liblz4.dll
liblzma-5.dll
libnettle-7.dll
libxml2-2.dll
libzstd.dll
zlib1.dll
Now that you got all those .dlls in one place, you have to make sure, the installer finds them when running pip
:
C:\Windows\System32\
, which would be the easiest way.pip install libarchive
and everything works.Alternatively, install python libarchive and the put the .dll files into your program/script folder where you need libarchive:
cmd
and execute set Path=%PATH%;<libarchive_source>\bin
(replace the <...> part). Do not add any quotation marks, even if the path has spaces. This just adds to the PATH for this cmd window, not the system PATH.pip install libarchive
.os.environ["PATH"] += os.pathsep + os.path.dirname(os.path.abspath(__file__))
. This appends the PATH variable inside your script (not system PATH) to include the folder the .py is in. In case you want to distribute the script you should probably choose this way.Please add some note to the PyPI repository and the github page linking to this guide or distribute a version that works on all OS. Thank you
This issue should probably be re-opened as there is no mention of how to get this working on Windows in the readme.
As the repo name is PyEasyArchive
I wouldn't expect to have to compile something on my own. That definitely makes it not "easy" for the average user. I was hoping to use this to see if I could extract an archive that py7zr cannot fully extract, but this is way too involved just to test if it will even work.
It needs libarchive to be available and in-scope.
Hi,
https://github.com/libarchive/libarchive/releases now provides binary libarchive.dll
for Windows.
How can I make it work with libarchive package? Thanks!
OK, here're my steps to install for Python 64bit on Windows:
OK, here're my steps to install for Python 64bit on Windows:
- download https://github.com/libarchive/libarchive/releases/download/v3.6.1/libarchive-v3.6.1-amd64.zip
- find and copy archive.dll inside zip and copy to a directory (e.g. your project directory or venv)
- rename it to 'libarchive.so'
- set an environment variable 'LD_LIBRARY_PATH' to the directory.
- pip install libarchive
this doesn't work,the erroe still exits
Python is a multi-platform programming language and as such libraries should also adhere to this concept. This library unfortunately does not work on most computers because it cannot find the libraries on Windows.
I will now explain how to compile libarchive.dll, so that one can install this python libarchive package.
- Get the x64 installer from https://www.msys2.org/ and run it.
- Go to the installation folder and run
mingw64.exe
.- Run
pacman -Syu
, restart the shell and runpacman -Su
.- Install minGW-64 via
pacman -S mingw-w64-x86_64-toolchain
.- Install minGW-64-cmake (not normal cmake, as this will lack minGW generators) via
pacman -S mingw-w64-x86_64-cmake
.- Install libxml2 via
pacman -S mingw-w64-x86_64-libxml2
.- Restart the shell.
- Download and extract the libarchive source: https://github.com/libarchive/libarchive/releases
- In the msys2 shell navigate to the extraced folder. You can access Windows paths via
cd /c/folder/subfolder
forc:\folder\subfolder
.- Create makefiles via
cmake . -G "MinGW Makefiles"
. You might have to run this twice, as the first time you might get an error about sh.exe.- Compile via
mingw32-make.exe
.libarchive.dll
is now in<libarchive_source\bin\libarchive.dll
.- In order to use this .dll you also need other dlls from the
<msys2>\mingw64\bin
folder. Copy those .dlls to the libarchive.dll folder:- libbz2-1.dll
- libexpat-1.dll
- libiconv-2.dll
- liblz4.dll
- liblzma-5.dll
- libnettle-7.dll
- libxml2-2.dll
- libzstd.dll
- zlib1.dll
Now that you got all those .dlls in one place, you have to make sure, the installer finds them when running
pip
:
- Bascially they have to be inside PATH, so you could copy them to
C:\Windows\System32\
, which would be the easiest way.- Finally you should be able to run
pip install libarchive
and everything works.Alternatively, install python libarchive and the put the .dll files into your program/script folder where you need libarchive:
- Run
cmd
and executeset Path=%PATH%;<libarchive_source>\bin
(replace the <...> part). Do not add any quotation marks, even if the path has spaces. This just adds to the PATH for this cmd window, not the system PATH.- Run
pip install libarchive
.- Copy all .dll files into the folder where your .py file is and add this to the top of your script (above the libarchive import):
os.environ["PATH"] += os.pathsep + os.path.dirname(os.path.abspath(__file__))
. This appends the PATH variable inside your script (not system PATH) to include the folder the .py is in. In case you want to distribute the script you should probably choose this way.Please add some note to the PyPI repository and the github page linking to this guide or distribute a version that works on all OS. Thank you
hi,i do what you list,but there's other errors: ############################
############################
Python recognizes 'libarchive.resources' as an importable package,
but it is not listed in the `packages` configuration of setuptools.
'libarchive.resources' has been automatically added to the distribution only
because it may contain data files, but this behavior is likely to change
in future versions of setuptools (and therefore is considered deprecated).
Please make sure that 'libarchive.resources' is included as a package by using
the `packages` configuration field or the proper discovery methods
(for example by using `find_namespace_packages(...)`/`find_namespace:`
instead of `find_packages(...)`/`find:`).
You can read more about "package discovery" and "data files" on setuptools
documentation page.
!!
check.warn(importable)
creating build\lib\libarchive\resources
copying libarchive\resources\README.rst -> build\lib\libarchive\resources
copying libarchive\resources\requirements.txt -> build\lib\libarchive\resources
C:\Python311\Lib\site-packages\setuptools\command\install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
warnings.warn(
--- Logging error ---
Traceback (most recent call last):
File "C:\Python311\Lib\logging\__init__.py", line 1113, in emit
stream.write(msg + self.terminator)
ValueError: underlying buffer has been detached
Call stack:
File "<string>", line 2, in <module>
File "<pip-setuptools-caller>", line 34, in <module>
File "C:\Users\baiya\AppData\Local\Temp\pip-install-x_hc726e\libarchive_a14e4efa1dc44001a08c4b04fc4e1c3f\setup.py", line 32, in <module>
setuptools.setup(
File "C:\Python311\Lib\site-packages\setuptools\__init__.py", line 87, in setup
return distutils.core.setup(**attrs)
File "C:\Python311\Lib\site-packages\setuptools\_distutils\core.py", line 185, in setup
return run_commands(dist)
File "C:\Python311\Lib\site-packages\setuptools\_distutils\core.py", line 201, in run_commands
dist.run_commands()
File "C:\Python311\Lib\site-packages\setuptools\_distutils\dist.py", line 968, in run_commands
self.run_command(cmd)
File "C:\Python311\Lib\site-packages\setuptools\dist.py", line 1217, in run_command
super().run_command(command)
File "C:\Python311\Lib\site-packages\setuptools\_distutils\dist.py", line 987, in run_command
cmd_obj.run()
File "C:\Python311\Lib\site-packages\wheel\bdist_wheel.py", line 397, in run
log.info(f"installing to {self.bdist_dir}")
Message: 'installing to build\\bdist.win-amd64\\wheel'
Arguments: ()
running install
error: Could not find module 'C:\Windows\system32\libarchive.dll' (or one of its dependencies). Try using the full path with constructor syntax.
Verifying that the library is accessible.
Library can not be loaded: Could not find module 'C:\Windows\system32\libarchive.dll' (or one of its dependencies). Try using the full path with constructor syntax.
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for libarchive Running setup.py clean for libarchive Failed to build libarchive ERROR: Could not build wheels for libarchive, which is required to install pyproject.toml-based projects i'm new to python,how could i solve this problem
I'm getting the following error when trying to do
pip install libarchive
on win 10: I have python 3.6 installed.