py-opencv import error in Bash for Windows 10 - python

I installed py-opencv in Bash for Windows 10 using Anaconda:
conda install -c conda-forge opencv
But when I import it in my Python3 interpreter, I get the following error:
ImportError: libopencv_reg.so.3.1: cannot enable executable stack as shared object requires: Invalid argument
It works fine on my Ubuntu machine so I figure this is a bug with Bash for Windows 10. If anyone has a work around it would be great.

Probably you have already found a solution, given the time that passed since you asked the question.
I faced the same problem and the solution in my case was installing opencv-python, which makes the bindings between OpenCV and Python. To install use the command sudo pip install opencv-python.
Works in the latest Windows build.

Related

Ubuntu terminal crashes while installing python package

I am trying to install mmcv python package, but Ubuntu terminal crashes every time during installaction (application simply closes without any errors). I tried to install this package both using standard Linux terminal and via VS Code - the result is always the same. It causes no errors when I install other python packages, but when I try to install mmcv - terminal crushes.
I am using this code for installation:
pip install mmcv-full==1.3.9 -f https://download.openmmlab.com/mmcv/dist/cu117/torch1.13.1/index.html
I tried to install mmcv using this code in Kaggle Kernel (it is Jupyter Notebook-like development environment, which works on Linux too) - and package was installed correctly.
It seems to me that my terminal crashes because mmcv is quite "heavy" python package, but I do not know what to do with it. How can I solve this problem and install mmcv?
It seems like my version of Ubuntu is not compatible with old versions of mmcv.
This code worked for me:
pip install -U openmim
mim install mmcv-full==1.5.0 -i https://pypi.tuna.tsinghua.edu.cn/simple

No module named open3d

I am trying to compile a python program (by running "python file.py"), but it gives me the error of "No module named open3d". I have installed open3d on my Mac system using "pip3 install open3d-python". I am also running python 3.10.4 64 bit.
I reinstalled python 3.10 and that comes with pip, so I am pretty sure that when I use pip to install packages they go in the same place. My vscode also doesn't show any errors when I am interpreting using 3.10, unlike 3.9 where there are yellow squiggles below my import line.
I have looked at other posts about a module not found but their fixes don't seem to work for me.
open3d library is currently not available for python version 3.10. I am solve it by installing with python 3.8.
The supported environment for open3d:
Supported Python versions:
3.6
3.7
3.8
3.9
Supported operating systems:
Ubuntu 18.04+
macOS 10.15+
Windows 10 (64-bit)
If you have other Python versions or operating systems, please refer to Build from source and compile Open3D from source.
Why did you install open3d with pip3 install open3d-python?
The official instruction gives pip3 install open3d.
Did you run your python via python in cmd? Maybe trying python3 could help.
pip install open3d work for me.

Pillow is installed, but still getting "ImportError: No module named PIL"

I did find this question asked by few more people, but none of those exactly met my situation, so asking here myself.
I've (rather had) two versions of Python (2.7 and 3.4.3) on my Mac running the latest MacOS High Sierra. As I understand, the v2.7 comes as default installation with the MacOS. And I installed the 3.4.3 (from .dmg file downloaded from the python site). Thus now, the python command defaults to the 2.7, while python3 points to the 3.4.3 in the terminal.
While trying to learn, I tried a python script that uses
import PIL and from PIL import Image
But when running, this gave the error ImportError: No module named PIL.
Upon research on google, I figured out to install PIL and Pillow using
sudo pip install Pillow
It installed correctly, but I'm still getting the same error.
To remove the confusion, I decided to remove the python 3.4.3 from the system. But even after it's removed, I still get the same error.
Even pip list displays Pillow 5.1.0 alright.
So right now, I've only Python 2.7, and the error persists, while Pillow is also in there.
which python gives /opt/local/bin/python as the path.
Does any of the above ring a bell? Any ideas, what else could be missing here?
Phew, finally found the issue. Thanks #Yash for the pointers.
Incidentally I did a which -a python and surprisingly got this output:
/opt/local/bin/python
/usr/bin/python
Damn, I don't remember when I installed a second 2.7 version on the /opt/local/bin folder (probably via macports). Alright, removed the confusion, deleted this python, so now I'm left only with the system installed python at /usr/bin.
And now the imports all run perfectly fine as expected. :-)
Try this,
sudo pip install image
I hope it works! One more thing, do check if you're running python3 filename.py instead of python filename.py, if you want to install it for Python 3, run the command,
sudo pip3 install Pillow
Basic Installation:
pip install Pillow
Windows Installation:
pip install Pillow
Reference: https://pillow.readthedocs.io/en/stable/installation.html
Try this. It worked for me
pip install --upgrade --force-reinstall pillow
If you get something like access denied error run the below command
pip install --upgrade --force-reinstall pillow --user

How to use Gcovr Installed with pip on windows

So I followed this guide and managed to install Gcovr using pip (I already have Python installed along with Anaconda). I tried to use gcovr but this is what I got:
When I use pip list, Gcovr is already installed.
How do I use it?
I'm running Windows 7 64bit with Python 3.5.2 :: Anaconda 4.2.0 64bit
P.S:
I'm sorry if this has already been asked before but after searching around for days I've yet to found any solution to my problem.
Using gcovr 3.x is a bit more cumbersome on Windows because Windows doesn't seem to recognize the gcovr script as an executable. Instead: find out where gcovr was installed to (e.g. by running pip in --verbose mode), then explicitly invoke Python:
> python C:\path\to\gcovr
The path is probably something like C:\Python35\Scripts.
You can also write a batch file to wrap gcovr like this.
Please also consider updating (pip install -U gcovr), as gcovr 3.4 fixes some other bugs on Windows.
This installation issue will be fixed in the next release. If you want to, you can already install the development version directly from GitHub:
> pip install git+https://github.com/gcovr/gcovr.git

ImportError: undefined symbol: _PyUnicodeUCS4_IsWhitespace

I am a python beginner and I would like some help with this. I am using Ubuntu and I had installed python using Anaconda, but then I tried to install it again using pip and now when I'm trying to run my code, at import numpy as np, I see this error
ImportError: /home/dev/.local/lib/python2.7/site-packages/numpy/core/multiarray.so: undefined symbol: _PyUnicodeUCS4_IsWhitespace
How can I fix this?
I also got this error. If you google for it, you will find lot's of similar issues. The problem can happen when you have multiple Python versions. In my case, I had the Ubuntu 16.04 Python 2.7 via /usr/bin/python and another Python 2.7 via Linuxbrew. type python gave me /u/zeyer/.linuxbrew/bin/python2, i.e. the Linuxbrew one. type pip2.7 gave me /u/zeyer/.local/bin/pip2.7, and looking into that file, it had the shebang #!/usr/bin/python, i.e. it was using the Ubuntu Python.
So, there are various solutions. You could just edit the pip2.7 file and change the shebang to #!/usr/bin/env python2.7. Or reinstall pip in some way.
In my case, I found that the Python 2.7 via Linuxbrew was incompatible to a few packages I needed (e.g. Tensorflow), so I unlinked it and use only the Ubuntu 16.04 Python 2.7 now.
Just uninstall numpy:
pip uninstall numpy
And reinstall numpy:
pip install numpy
Another thing you can do is run it on a virtual environment:
virtualenv myproject
cd myproject
source bin/activate
pip install numpy

Categories

Resources