What do I do if my package isn't being detected? - python

I am on Windows. If I run a piece of Python code including import manim, the following error message appears.
RuntimeWarning: Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work
warn("Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work", RuntimeWarning)
However, I have installed ffmpeg via pip. What should I do?

What should I do?
Install FFmpeg rather than ffmpeg python package. It is quite popular so you should be able to find tutorial relevant for your operating system, search for How to install FFmpeg (your operating system name here) or similar.

Related

FFmpeg not found for manim installation

I was trying to install manim so I ran the following commands in my VScode terminal
>>pip install manim
>>pip install FFmpeg-python
However, when I ran a sample manim program on VScode(copy pasted from the tutorial), I received the following information.
RuntimeWarning: Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work
warn("Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work", RuntimeWarning)
I have tried downloading a pre-compiled ffmpeg from https://ffmpeg.org/download.html#build-windows, but when I downloaded it there was no way to unzip it.
My code below:
from manim import *
class CreateCircle(Scene):
def construct(self):
circle = Circle() # create a circle
circle.set_fill(PINK, opacity=0.5) # set the color and transparency
self.play(Create(circle)) # show the circle on screen
Tutorial/Installation guide link I used:
https://docs.manim.community/en/stable/installation/windows.html#required-dependencies
Please note that I am on a windows 64-bit computer
Can anyone help me install manim or ffmpeg properly?
ffmpeg is not a Python library, you can't install it with pip.
You might be able to use Windows' package manager to install it by running winget install ffmpeg in your PowerShell. And if you prefer to install ffmpeg manually, instructions can be found in Manim's documentation.

How to fix Issue with PyAudio in Python

I tried installing Pyaudio in Python but Python says it requires Portaudio binding for the installation.Help me fix this please.My platform is Windows.I am using Python 3.7.2.
I did:
1.I followed the instructions provided in the portaudio website and generated dll file using visual studio.
The portaudio directory where the compiled files are located is my Desktop.
2.Anyway I have installed pyaudio using a setup(exe) file which i found somewhere.
So whenever i type the command "pip install pyaudio", it says the requirements are already fulfilled.
But when i use the alternative command "easy_install pyaudio",it shows an error related to portaudio.
3.And whenever I run a python file which uses pyaudio it again says binding is required.
So, I need the solution to bind Portaudio files which are in my desktop with python.
I searched everywhere for the solution but since I am a beginner, all the tutorials provided in different websites were hard to understand for me.
So please help me with a simple and descriptive solution.
Thanks in advance.
ouch, it seems like you have chosen a painful way to get pyaudio installed.
I never compile on windows, if I can't find a pre-compiled binary I will look around for a different way to get to where I want to (different library…)
you can uninstall with pip uninstall pyaudio
anyways, here's one way to get it working.
download and install a "miniconda" (google if you don't know what it is)
do conda install pyaudio in your "conda"-prompt
I did not truly check the install, but I did the conda install… and it would have installed both portaudio and pyaudio so I suppose it will work.

Python3.4 error - Cannot enable executable stack as shared object requires: Invalid argument

I've been trying to install OpenCV in a Bash on Windows (Windows Subsystem for Linux, wsl) environment and it's been proving very difficult.
I think I'm getting very close, but upon entering python, import cv2 gives the following error:
ImportError: libopencv_core.so.3.1: cannot enable executable stack as shared object requires: Invalid argument
How do I enable the library to execute on the stack?
My OpenCV *opencv*.so* library files are located in /usr/local/lib/. In a normal Linux environment, I would grant these libraries the ability to execute on the stack using
execstack -c /usr/local/lib/*opencv*.so*
However, even though I can successfully download the execstack package, it isn't a recognized command I can run to allow execution on the stack. I suspect this has something to do with Data Execution Prevention, Window's version of Exec-Shield to prevent stack smashing attacks.
But maybe I've just been too close to the problem to figure out what's wrong. Why can't I import this python package? I'm using Python v3.4 and OpenCV compiled from the latest source code (v.3.1).
I solved this problem following this:tatsuya-y.hatenablog.com
I use windows bash and install opencv by conda install -c menpo opencv3=3.1.0
then I got this (python 2.7)
>>>import cv2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: libopencv_ccalib.so.3.1: cannot enable executable stack as shared object requires: Invalid argument
I solve it by execstackcommand
sudo apt-get install execstack
sudo execstack -c $HOME/anaconda2/lib/libopencv_*
Then sudo apt-get install gtk2.0-0
Problem solved! >>> cv2.__version__
'3.1.0'
Remember that the opencv libraries are installed to /usr/local/lib if following the installation instructions online. Thus, the command would be:
sudo execstack -c /usr/local/lib/libopencv_*
There are lots of things that simply don't work at the moment, because there are either unimplemented syscalls (WSL only has partial coverage, only about 70% of syscalls are implemented, some of them only partially), or missing socket modes and options (WSL does not yet support Unix datagram sockets, although it should be available in the next insider build).
If you go to the github (BashOnWindows) and post an strace or search for your issue and find a copy of it, that's the best way to get an answer. The Microsoft team working on this project wants lots and lots of feedback and bugtesting.
To be clear, I am saying that you are 100% running into something that isn't implemented yet. However, there might be a way, if you look at the sourcecode for your .so file to disable the part of the code that uses that syscall (since Python is crossplatform and not all Linux syscalls are supported across all *nix operating systems).
I also had the same problem but I was able to fix it by just re-installing it
$ sudo apt-get install execstack
and the comment mentioned above in Windows 10 build 14393.479
You can use execstack for installing opencv and even importing the lib. Yet for doing video capture, as in cv2.VideoCapture(0), bash for windows won't work. You need to have a full distribution installed.

3D Harmonics library on windows - pyshtools failed building wheel + fatal error with fftw3.lib

We need a tool to work with 3D-Harmonics and we've come across https://github.com/SHTOOLS/SHTOOLS - which fits all of our needs, but could not be installed properly on our windows computers (as it's intended for linux\osx).
When we tried to run pip install . in the directory SHTOOLS-3.3 (we use anaconda for managing packages and it includes pip), we at first got an error saying that we need a Fortran compiler (gfortran) - which we fixed by installing gcc with conda install -c r gcc. Afterwards, we got an error saying we need to install visual C++ compiler - which we downloaded as suggested from https://www.microsoft.com/en-gb/download/details.aspx?id=44266.
Alas, running the command again, this time from the visual C++ 2008 command prompt, we still get a fatal error and are still stuck with installing the library.
Some of the errors we get:
could not find library 'fftw3' in directories ['build\\temp.win-amd64-2.7']
could not find library 'm' in directories ['build\\temp.win-amd64-2.7']
could not find library 'lapack' in directories ['build\\temp.win-amd64-2.7']
could not find library 'blas' in directories ['build\\temp.win-amd64-2.7']
Followed by
LINK: fatal error LNK1181: cannot open input file 'fftw3.lib'
and
Failed building wheel for pyshtools
The full output of the installation attempt can be found here and here.
We've tried to download the lib files of the FFTW3, LAPACK and BLAS libraries but couldn't build them properly.
We would appreciate any help (suggesting a similar library that is compatible with windows \ helping with the install of SHTOOlS).
It's a shame when you find something ready to go but very time consuming to make it work on windows. My advice would be avoid the hazzle of installing that non-ready-to-go-on-windows library and just looking for another alternative, there are few ones dealing with spherical harmonics. What about this one? pyspharm
Also, posting an issue in the library's github issues could speed it up things.

Installing modules reliably in one location

I've been working with Python for a little while now but have come to absolutely detest installing new modules. It always seems to take me a full work day to install one additional module. This last happened with mpl_toolkits and now it is happening with gdal.
The main issue seems to be that easy_install/pip/get-app aren't saving a file in the correct location and so Python (I'm using Spyder) can't find it. How do I install a module in a location so that Python can find it?
I have been reading guides, articles, manuals and Stack Overflow articles all day now and I feel this needs a new question as I can't find an answer.
It is installing fine, it's just Python (and I) can't find it
It's not in the /lib/python2.7/site-packages folder, which seems to be the Python default, although half the modules that do work aren't in there when I list it
I installed using:
sudo apt-get install gdal-bin
I also tried with:
pip install gdal
but this fails with the error:
Command "python setup.py egg_info" failed with the error code 1 in /tmp/pip-build-NWJT2f/gdal/
I looked for the files using
dpkg -L gdal
and then added the file path this said into Spyder's preferences option for PYTHONPATH, but it still couldn't find it and so I'm guessing this is wrong.
I have read the official documentation of PYTHONPATH, but it's very short and doesn't really explain it at all.
I recommend trying anaconda or miniconda, which manage environments and install packages - it 'just works'.
https://www.continuum.io/downloads

Categories

Resources