from unrar import rarfile
If you are using an IDE like PyCharm on Windows, it will prompt you to import packages, or you can manually search for third-party libraries in the project Settings and install them.
It is recommended to use the PIP install rarfile and PIP install unrar commands to install these libraries if it is a Linux command environment.
However, you will notice that after doing the above, the Python program does not decompress and it will say Couldn’t find path to Unrar Library… An error caused the program to interrupt.
At that time, I was puzzled. I installed the library, why can’t I find it?
After several checks, from the Python – Unrar open source project official website learned that Python under the Unrar also relies on the RAR official library.
So, the next two Windows and Linux systems to introduce the solution steps.
1. Go to the RARLab official download library files, http://www.rarlab.com/rar/UnRARDLL.exe, and installation;
2. It is best to choose the default path for installation, usually in the C: Program Files (x86)\ Unrardll \ directory;
3. Then the important step is to add the environment variable, this computer (my computer) right click, properties, find advanced system Settings, advanced TAB click environment variable, in the system variable (note not user variable) in the new, variable name input UNRAR_LIB_PATH, must be exactly the same, the value of the variable should pay special attention to! If you are a 64-bit system, type C:\Program Files (x86)\ Unrardll \x64\ Unrar64.dll, if you are a 32-bit system, type C:\Program Files (x86)\ Unrard.dll.
4. Once you are sure to save your environment variables, restart your PyCharm with the same code and run it again without any errors. At this point the dependent libraries have been added to the system environment.
Linux needs to manually compile and generate the SO file itself, which is a bit more cumbersome:
1. In the same way, the first to download the Source file, but it’s not like a Win for you packaging good, you need to download the Source code: http://www.rarlab.com/rar/unrarsrc-5.4.5.tar.gz, namely RARLab website to download the list of UnRAR Source, you can download the latest version;
Make install-lib will automatically compile the library files. After the compilation is complete, use the make install-lib command to generate the libunrar.so file (usually under /usr/lib).
3. Finally, you still need to set the environment variable of your Linux system, find the profile file in the /etc/profile directory, which you can edit directly using the Vim /etc/profile command (even more convenient with WinSCP), add export UNRAR_LIB_PATH=/usr/lib/libunrar.so at the end of the profile, don’t put the comma in it. Save the variable successfully and then use the source /etc/profile command to make the variable effective.
4. If you run the py file again, you won’t get an error, at least you won’t get a warning that you can’t find the unrar library.
Sudo apt-get install g++ : sudo apt-get install g++ : sudo apt-get install g++ : sudo apt-get install g++ : sudo apt-get install
In conclusion, the normal order of installation should be to install the dependent libraries, configure the environment variables, and then PIP install unrar or import unrar libraries in the IDE. However, you can only make up for the error, and the final effect is the same.
- Could’t find path to unrear Library
- LookupError: Couldn’t find path to unrar library.
- Using Unrar to decompress rar file
- The app failed to start because there is no Qt platform to initialize
- Lookuperror: couldn’t find path to unrear library! two thousand and twenty
- Solve the problem of Python in Windows environment: Fatal error in launcher: Unable to create process using’”‘ in pip installation
- Error: /usr/bin/python: Error while finding module specification for ‘virtualenvwrapper.hook_loader’
- |-OpenGL – | some small problems about the glut Library
- source, ~/.bashrc, ~/.bash_ Profile details
- ExecutableNotFound: failed to execute [‘dot’, ‘-Tsvg’], make sure the Graphviz executables are on yo
- (Copy python package, the problem generated) pip Fatal error in launcher: Unable to create process using
- Configuring OpenGL development environment in win10 + vs2015 (including the method of installing 32-bit and 64 bit libraries)
- Installation of Python on MAC
- UnicodeEncodeError: ‘ascii’ codec can’t encode characters in position 0-2: ordinal not in range(128)
- ImportError: ‘DLL load failed: %1 is not a valid Win32 application.
- Cocoapods- ERROR: Error installing cocoapods: ERROR: Failed to build gem native extension.
- Error running Eclipse: failed to load the JNI shared library
- Under win864 bit, install python, PyQt4 and sip. (final failure, only record)
- CMake error: error in configuration process, project files may be invalid
- Raspberry pie upgrade to Python 3.7.3