I need uncompress .rar file in Google Colab with Python3. First I tried to do localy in MacOS.
I have installed Patoolib package:
pip install patool
and unrar to unzip .rar files
brew install unrar
Then, In my python script I do:
import patoolib
patoolib.extract_archive("data_2/Peliculas.rar", outdir="/data_2")
and I get the following error :
PatoolError: could not find an executable program to extract format rar; candidates are (rar,unrar,7z),
I need to configure Patool to use unrar but there is no documentation available. Somebody knows how to solve this error?
My issue was solved by simply adding my Winrar directory to my Path (in system environment variables). Made the horrible mistake of assuming it was set up by default (because why wouldn't it, it's already on the contextual menus right?), but that was not the case.
Hope this helps whoever reads this
Related
whenever I type, for an example: pip install aiohttp==3.7.3, it gives me: /usr/bin/env: ‘./python3’: No such file or directory is there any way to fix it? (The error is in REPLIT)
I had problems with using aiohttp in REPLIT, I tried uninstalling package files. I "reinstalled" packages, such as "aiohttp" after doing the problem referred to the title popped up in the console.
I ran into this error as well and haven't been able to solve it.
In the meantime, I use python3 -m instead and it works:
python3 -m <module-name> <args>
Well, go to .replit and delete the Variable called hidden = ["venv", ".config", "**/__pycache__", "**/.mypy_cache", "**/*.pyc"]
after deleting, go to the file directly and download the module to your computer, then upload it to the file it's not in.
I hope this works,
-JKID_Tech
P.S. I tried this IT WORKS if you get python from your computer then go to the python files or try to find it on the internet for example PyPI
I can't unpack a .rar file using patoolib in Python.
I always get the error message:
PatoolError: could not find an executable program to extract format rar; candidates are (rar,unrar,7z),
I'm using macOS, Anaconda Navigator with Spyder IDE, and I have already installed unrar package. I don't understand why patool can't find the executable program and I'm not able to solve this problem.
Can someone tell me how to solve?
EDIT:
The error arises when I call this method, that I defined to unpack both .zip and .rar files:
def unzip_file(path_to_file, out_dir):
# Extracts path_to_file in out_dir
if path_to_file[-3:] == 'zip':
with zipfile.ZipFile(path_to_file, 'r') as zip_ref:
zip_ref.extractall(out_dir)
return
if path_to_file[-3:] == 'rar':
patoolib.extract_archive(path_to_file, outdir=out_dir)
return
raise FileNotFoundError(path_to_file)
You're on macOS, you should probably installHomebrew if it's not installed, and then run brew install 7z and try again.
I'm guessing that this tool you're using doesn't do the actual archiving, it just knows how to talk to the various archive programs out there, and so you need to have installed one that can read and write RAR archives.
I have downloaded a python package to install, on my ubuntu machine. The package has already a setup.py file to use, but I want to change the default python installation address to something else, for this package specifically (and not for good). So what I tried is:
First in the terminal, I export that address of the new folder:
export PYTHONPATH=${PYTHONPATH}:${HOME}/Documents/testfolder/lib/python2.7/site-packages
Then I add this exported address as prefix to the installation command:
python setup.py install --prefix=~/Documents/testfolder
The installation goes through. Now to make python always look for this new path as well (next to the default installation path), I export the address in bashrc file:
export PYTHONPATH="${PYTHONPATH}:~/Documents/testfolder/lib/python2.7/site-packages"
But now whenever I open a terminal and try to import the installed package, it cannot see ("no module named..."). Only when I open a terminal in the folder where I had the installation files (namely setup.py), and run python, can it then see the package, and it works there.
Why isn't my export in bashrc making the package available from anywhere?
Is there something I have done wrong in the above?
To answer your question about the export path. Do you have $PYTHONPATH as a part of your $PATH? If not you should add it to path.
The best way to handle this scenario in my opinion is to use a virtual python environment. There are a couple to choose from, but I like virtualenv the best. The reason to take this approach is because you can manage different versions of python in separate folders. And have separate packages installed in these folders. I recommend looking into it as it is a very useful tool. If you want an examole of how to use it i can provide that https://virtualenv.pypa.io/en/stable/
I'm working on a project for which I need to a module. I want to know how to import some other module in python that is not installed.
When I write
import xaut
It gives error no module named xaut.
I have xaut-0.4.5 that I downloaded from following link.
Please help me how to use it.
Well I think following will help
Extract your zip file
Open the command line (a linux terminal or cmd on windows). I am on linux so I have a terminal.
Now enter the directory that you have extracted.
In it is a directory "python" cd into it.
If you run the ls command (if on windows run dir) you will see that in this directory there is a script "setup.py". We need to execute it for installation.
Execute this script by giving command python setup.py install
This will hopefully install it and then you would be able to import it.
Basically you have only downloaded the package. To make a package work you also need to install it. So when you download a package always search for a setup.py file.
This is certainly a duplicate question. You can look up how to add a python module to the path in windows.
here is an example
How to add to the pythonpath in windows 7?
I have a program written in python 3.3 that I'd like to be able to distribute without the need for users to install python or any additional modules. I was able to successfully package this program using cx_Freeze on Windows, but the same script on OS X produced an app that wouldn't launch.
I thought I might have better luck using py2app, but now I'm running into a strange problem. The program opens (it has a GUI built with tkinter) and runs flawlessly when built in Alias mode. When I attempt to construct a final build, however, I get the following message in Terminal:
error: No such file or directory: /Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/setuptools-2.1-py3.3.egg/_markerlib/__init__.pyc
I navigated to that directory and found a .egg file that I'm unable to open or extract. I've tried reinstalling setup tools and well as python itself with no luck. Has anyone experienced this problem?
It looks like the problem is that your setuptools is somehow broken.
To open the egg file, I tried downloading a third party tool, which crashed, and renaming it as a .zip, which failed. If I just double click on it, I get the "choose default application" popup.
Double-clicking it relies on the extension to decide what app to launch.
The best way to check whether something is a valid zip file is to use the unzip tool from the command line. For example:
$ unzip -t setuptools.egg
This will check all of the zip headers, and check the CRC of all files in the archive, and report any errors. Or, if it's not a zip at all, it'll report one error right at the start.
You can also use the file command to do a quick check to see whether it's some well-known type of file. If file /path/to/setuptools-whatever.egg just says "data" instead of "Zip archive data", then it's probably corrupted beyond recognition.
Anyway, assuming your setuptools didn't come with your Python installation (if you're using a python.org binary installer, it didn't), the safest thing to do is uninstall it, then reinstall it cleanly.
The reason it's important to uninstall first is that the current version will, by default, not install a .egg archive, but will instead install a normal unzipped package and egg-info directory, meaning it may not overwrite the old, broken copy.
The documentation covers uninstalling. Just delete the setuptools .egg file, and anything else named setuptools*, from your site-packages (and anywhere else on your sys.path). If you have distribute there as well, kill that too. This will leave a few files sitting around in other places (notably easy_install-3.3 somewhere on your PATH), but they'll get overwritten properly by the installation, so that's OK.
To install, just follow the usual instructions to reinstall it:
$ wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py -O - | python
… or, if you don't have write access to site-packages:
$ wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py -O - | sudo python
If you use pip, you may want to reinstall it after reinstalling setuptools, and then pip install -U setuptools pip just to make sure you have the latest versions—and to verify that everything is now working.