Unable to use patoolib after 'pip3 install patool' - python

I am using a macbook, and have python3 installed and using spyder.
I have installed patool and it's listed in pip3 list.
When I import patoolib and run the program it says, ModuleNotFoundError: No module named 'patoolib'
So I am not able to run the extract related programs.
import patoolib
import os
import glob
def extract_files(inputdir = '/Users/satishvadlamudi/Python_spyder_projects/zipped',outputdir = '/Users/satishvadlamudi/Python_spyder_projects/extracted'):
os.chdir(inputdir)
archives = glob.glob('*.gz')
#print(archives)
if not os.path.exists(outputdir):
os.mkdirs(outputdir)
files = os.listdir('/Users/satishvadlamudi/Python_spyder_projects/extracted')
print (files)
for archive in archives:
if archive[:-3] not in files:
patoolib.extract_archive(archive, outdir = outputdir)

Note that "pip" is also a python module. If you see pip3 list give you the module installed but python3 complaint about ModuleNotFoundError, you may want to check if pip3 and python3 mean the same thing.
Try with python3 -m pip list -v, which the -v tells you the installed location as well. If you see the module there, then the same python3 interpretor should be able to find the module. If not, you may want to consider setting up PYTHONPATH env variable.

In order to import :
import patoolib
you need to install patool first :
pip install patool

Related

Error ModuleNotFoundError: No module named 'pdf2docx'

I am having an issue to work with the lib pdf2docx.
Here is the code I am trying to work
from pdf2docx import Converter
pdf_file = 'test_file.pdf'
docx_file = 'test_file.docx'
# convert pdf to docx
cv = Converter(pdf_file)
cv.convert(docx_file, start=0, end=None)
cv.close()
I have installed the lib using pip install pdf2docx and I have tried as well to use sudo.
I tried to use as venv like:
create a folder
inside this folder, open your command line(cmd)
pip install virtualenv
virtualenv venv
pip install pdf2docx
Any idea about how I can make the script working?
Require Python >= 3.6. pdf2docx can be installed through:
python3 -m pip install pdf2docx
I just solved the issue, it looks like I am unable to run the script using Vstudio. The script works using the command line like python3 pdf_to_docx.py.

ImportError: No module named scenedetect on Linux Ubuntu

I'm trying to use pyscenedetect library on python for videos but I get this error when using the python interface and when I use the command line interface I get the error "ModuleNotFoundError: No module named 'cv2'"
even though I believe I installed both correctly according to the documentations.
I have trying to look for different ways to import opencv for the second error but to no avail. As for the first error i can't find any answers to my problem.
import cv2
import numpy as numpy
import os
import scenedetect
from scenedetect.video_manager import VideoManager
from scenedetect.scene_manager import SceneManager
from scenedetect.frame_timecode import FrameTimecode
from scenedetect.stats_manager import StatsManager
from scenedetect.detectors import ContentDetector
If you have pip you can try
pip install opencv-python
If you have anaconoda, you can try
conda install -c conda-forge opencv
it's probable that you installed it on a different python installation in your PC.
To know where your python installation is you can launch python and:
import sys
sys.path
To get the list of everything you have installed you can:
pip freeze > installed_modules.txt
Try only running
import cv2
So that you can test it
I found the problem. As Ivan was pointing out, the problem was with openCV.
I used the following command:
sudo apt install python3-opencv

Why doesn't module import while it actually exists?

My project structure looks like the following:
my-project:
dialog
utils
path.py
After install by 'pip install .', in PyCharm, I can import successfully either of the two:
from dialog.utils import path
import dialog.utils
Then I can refer to it as below:
path.module_path() // OR
dialog.utils.module_path()
It doesn't run into any problem. I can also do this in iPython's terminal. However, when I run a python through terminal:
python3 run_dialog
run_dialog.py import 'path' as shown above, it always reports this problem:
Traceback (most recent call last):
File "run_dialog.py", line 15, in <module>
import dialog.utils
ModuleNotFoundError: No module named 'dialog.utils'
So basically, I can run this code in both PyCharm and iPython terminal, but not in the project with 'python3 run_dialog'.
Why is that?
Try this
import sys
sys.path.append('my/path/to/myModule/dir')
import myModule
The Python interpreter needs to know to path to your imported module.
However, a better approach would be setting PYTHONPATH to your project directory like this
set PYTHONPATH=my/path/to/project
In my humble opinion, the Pythonic solution would be to install your package in the activated virtual environment using an "editable" install.
“Editable” installs are fundamentally “setuptools develop mode” installs.
use the pip install -e <path> option to do an editable install
(venv) $ pip install -e path/to/myproject # wherever myproject/setup.py is located
you can use pip list to confirm your package is installed into the virtualenv as an editable package, ie the path to the package is listed
$ pip list
myproject 0.1 path/to/myproject
pip 19.1.1
setuptools 41.0.1
changes saved to your package take effect each time you restart the interpreter and reload/import the package, letting you "edit" or "develop" your package

Python: ModuleNotFound Error

I downloaded multiple modules (Discord API, cx_Freeze) (pip download, Windows 10) and now I wanted to use them.
But when I want to import them, it says there isn’t any module.
From my former Python using (before resetting computer) I‘ve added a pycache folder and it worked for one module. I‘m not able to reproduce it for other modules. What to do?
I‘ve only one Python version (3.6.5) on PC.
I‘ve checked the \site-packages folder and they‘re there.
If you are using python3 then try downloading the library using
pip3 install libname
but if you are using python2 then install the library using
pip2 install libname or just pip install libname
try with these command and reply
try installing your library using the command prompt in normal user and with the admin user so that you will get to know that what is happening and also if it is still not working then try installing the library into the same folder of your project using pip custom install command
pip install -t <direct directory> <package>
then use the import statement
For Example I used
pip2 install -t c:\Users\Nav\Desktop\projectss cx_freeze
then i imported the library using
#from cx_Freeze import setup, Executable
import cx_Freeze
from cx_Freeze import *
it worked.
Previously i was getting error like :
File "C:\Python27\lib\site-packages\cx_Freeze\__init__.py", line 10, in <module>
from cx_Freeze.finder import *
ImportError: No module named finder
After custom install it is working

Import error installing tlslite

I'm trying to install tlslite. After installed the module I've tried to test it and I receive this error:
from .checker import Checker
ImportError: No module named checker
I've checked on my pip module list and checker is installed...
Any idea?
Thanks!
Assuming you installed tlslite correctly, try this:
>>> from tlslite.checker import Checker
If that doesn't work, check that tlslite is in your site packages
To work with tlslite I recommend to use a virtualenv and install TlsLite inside:
cd ~/virtualenv/ # <- all my virtualenv are here
virtualenv myvenv
source ~/virtualenv/myvenv/bin/activate
pip install -q -U pip setuptools # ensure last version
pip install tlslite
With that in hand, you can use the Checker:
$ python
>>> from tlslite.checker import Checker
>>>
Et voilà !

Categories