Python-Magic ; Unable to find libmagic [duplicate] - python

This question already has answers here:
Python-magic installation error - ImportError: failed to find libmagic
(5 answers)
Closed 8 years ago.
I've downloaded and installed python-magic using "pip install python-magic".
Source: https://github.com/ahupp/python-magic
It downloaded and installed perfectly fine. I've also copied the 3 files (cygmagic-1.dll, cygwin1.dll, and cygz.dll) from cygwin installation into C:\Windows\System32.
Then, I also downloaded magic1.dll and placed it in System32 folder too.
But the command prompt is still giving me this error:
ImportError: failed to find libmagic. Check your installation
Why is this so?
EDIT: I've included C:\cygwin\bin into PATH also.

Make sure you also included
C:\cygwin\bin
in your system path. That seems to be the step missing.

Oh I just have to restart the computer for it to work. But ultimately, I still have problems using python-magic because of the "32bit" and "64bit" incompatibility bug. I guess I'll just check the file type by checking the extensions. Oh well.

Related

Python package in the wrong path leading to ModuleNotFoundError [duplicate]

This question already has answers here:
pdfminer - ImportError: No module named pdfminer.pdfdocument
(4 answers)
Closed 4 months ago.
I have found a few solutions here and elsewhere, but none of them has worked. Context: I am trying to get pdf2txt going on my Pop!_OS 22.04 LTS system. I am using Python 3.10.6, with no other versions present. The command-line states that it requires python3-pdfminer to work, which I installed with apt. Output states that there is no module named 'pdfminer.high_level'. This comment here notes that it's a part of pdfminer.six which can be installed using pip, using a dash instead of a dot if it's inside a virtual environment.
$ python3 -m pip install pdfminer.six
states that requirements are already satisfied. To be sure, I also switched to a virtualenv and installed it there:
$ pip install pdfminer-six
Running pdf2txt in both cases results in the same error, i.e.
File "/usr/bin/pdf2txt", line 9, in <module>
import pdfminer.high_level
ModuleNotFoundError: No module named 'pdfminer.high_level'
I then tried to uninstall and reinstall pdfminer.six, first on the system wide version. python3 -m pip uninstall pdfminer.six (or just pip3) was not allowed, so I made a judgment of error and used sudo. Reinstalling now shows:
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: pdfminer.six in /usr/lib/python3/dist-packages (-VERSION-)
so I am not sure if it is properly installed. So I tried in the virtualenv where there were no problems. But the same error remains.
I reinstalled python3-pdfminer but without success.
In the virtualenv, I found:
./lib/python3.10/site-packages/pdfminer/high_level.py
./lib/python3.10/site-packages/pdfminer/__pycache__/high_level.cpython-310.pyc
I then created a test Python file that imports pdfminer.high_level and ran it, with no problem. I then did the same outside the virtualenv. pdfminer is imported correctly, but it can't import pdfminer.high_level. So I found the following:
When I uninstall pdfminer.six, it looks in /usr/local/lib/python3.10/dist-packages and removes it from there.
When I install pdfminer.six, it looks in /usr/lib/python3/dist-packages. Here, the high_level package is present. But the system always looks in /usr/local/lib/python3.10/dist-packages, so the package is never found.
So, I think that I found the cause of the problem. Running pdf2txt doesn't work in the virtualenv because it's still a file in /usr/bin that will look for a system-wide version. I suppose that I can update a system environment path to point to /usr/lib/python3/dist-packages, and solve it like this (pdf2txt is actually not binary so I can append to sys.path). But why has this discrepancy occurred in the first place? And what is the proper way to deal with it? After all, there is a reason why some packages are installed in different locations.
Many thanks.
EDIT: Adding to sys.path doesn't work, but adding to PYTHONPATH does. Not sure if this is something that I should watch out for in the future, or just a result of a Python executable installed in /usr/bin messing up with the idea of using a virtualenv in the first place.
Sometimes this issue happens when you have same name file in your working dir. So please check that first like if you have a file name "pdfminer.py".
If that is not the case then I usually try the previous version of lib.
you can try installing previous version with
pip install pdfminer.six==20220506

Failing to download pandas_datareader package in PyCharm [duplicate]

This question already has answers here:
How do I use installed packages in PyCharm?
(14 answers)
Closed 1 year ago.
When I try to download the package using the GitHub URL it tells me I have an error. I attached a screenshot for this particular issue.
I have also tried to install it through the console and it successfully ran but it does not show in my installed packages in PyCharm. When I go to the folder the packages are in it is there so i try to make PyCharm recognize it but I am told the setup.py file does not exists.
I also tried to download the zip file and unpack it in the right folder and try to install it that way in PyCharm and it still fails. In this file the setup.py file exists but I am still told it does not.
Ok so your problem is that you dont have git installed in your system. In windows its just a file executable for LINUX you can visit https://www.activestate.com/resources/quick-reads/pip-install-git/

PyCharm install package with square brackets [duplicate]

This question already has answers here:
'pip' is not recognized as an internal or external command
(40 answers)
Closed 1 year ago.
I want to install "stabe-baselines3[extra]"
But in the PyCharm Package installer is only "stable-baselines3" available.
When try to install it via 'pip install' I do get this error:
Translation: 'pip' is not recognized as an internal or external command
How do I get the [extra]?
From: https://github.com/DLR-RM/stable-baselines3
So are you actually needing that additional functionality for atari games?
If so, then you can just use the built-in Terminal to manually install the package you are needing:
Which if you didn't already know, can be found right here:
Otherwise, you can just use stable-baselines3, as you have already found is available within the package manager.
The terminal has to be used. Reason the terminal hasn't worked is because in the settings 'Start directory' hasn't been the Python Scripts folder but the main-file folder.
After that folder change the pip install command worked!

Installing packages in Python 2.7.9 [duplicate]

This question already has answers here:
error: Unable to find vcvarsall.bat
(42 answers)
Closed 8 years ago.
I'm brushing up on my Python and have recently installed ver. 2.7.9 on my Win7 64-bit PC. I tried installing a couple of packages (numpy 1.9.1 and scipy 0.15.1) but I get errors through the process. I ran:
> python setup.py install
from the folder of each package and although the setup script ran, neither of the packages got installed. I got the following errors:
numpy: Unable to find vsvarsall.bat
scipy: No module named numpy.distutils.core (???)
Note that I haven't tampered with the packages files at all, which I extracted from the .tar files available in the Python Package Index database. I'd appreciate any help on this matter.
The go-to repository for Windows modules is Christoph Gohlke's Python Extension Packages for Windows site. He has both numpy and scipy available. To install, download the appropriate .whl file, then run
pip install name_of_file.whl
to install the module. pip should have been installed automatically when you installed 2.7.9, if the command is not found, make sure you add C:\Python27\Scripts to your PATH and restart the command prompt.

How to install the module pysqlite2 [duplicate]

This question already has answers here:
error: Unable to find vcvarsall.bat
(42 answers)
Closed 8 years ago.
I want to install the PySqlite2 module in my python library. I opened command prompt and went to the download directory. This contains the Pysqlite-2.6.3 package extracted. I entered python setup.py install. It starts copying all the files untill it gives: Errror: Unable to find vcvarsall.bat. I can't seem to figure to out. My systems runs a 32bit version of windows 7.
While running setup.py for package installations Python 2.7 searches for an installed Visual Studio 2008. You can trick Python to use a newer Visual Studio by setting the correct path in VS90COMNTOOLS environment variable before calling setup.py.
Find more here.

Categories

Resources