import Error: No Module named cropresize - python

I am new to python. I am working on some other's project but when i tried to run the code it give me the error said above. My all pages are working properly except those in which i had images. Is there any library required for the same??
Any help will be appreciable.
Thanks

you need to have cropresize package http://pypi.python.org/pypi/cropresize/ installed on your device.
If it is not there install it from the link
Do easy_install cropresize or pip install cropresize

Just do easy_install cropresize.

cropresize package needs to be installed! First install pip(Ubuntu/Debian):
sudo apt-get install python-pip
Then install cropresize using pip:
pip install cropresize

cropresize (all versions) depends on PIL.
Unfortunately, Pillow (installed) does not satisfy this dependency when using pip or easy_install :(

Related

No graphing with igraph [duplicate]

I have Python 2.6 in my Linux rhel-5. I have installed pip and required CFFI packages. When I try to run a sample CFFI program:
ffi = FFI()
it says:
File "/usr/lib/python2.6/site-packages/cffi/api.py", line 56, in __init__
import _cffi_backend as backend
ImportError: No module named _cffi_backend
What could be the possible error? Did I miss something during installation? I have installed pip, wheel, pycparser, pytest and cffi.
For python2.x use following command:
python -m pip install cffi
for python3.x
python3 -m pip install cffi
I needed to uninstall and install it again:
sudo pip uninstall cryptography
sudo pip uninstall paramiko
then install pagamiko again
sudo pip install paramiko
and it start to work for me
I recently had the same issue and none of the above solutions worked for me.
Here is what worked.
sudo apt remove python3-cffi
sudo python3 -m pip install cffi
Did you compile Python from source, and if so, did it give you any errors during the configure/make/make install phase? Compiling Python from source can be a real beast on older Red Hat systems, so if you installed that way, I'd suggest combing through the configure and make output to be sure that no modules were left out.
In order to get pip install cffi to succeed with no errors, I had to install gcc and libffi-devel from the EL5 repos. From there, I was able to instantiate an FFI instance with no problems:
>>> from cffi import FFI
>>> ffi = FFI()
>>>
Here's the output of pip freeze, for reference:
[root#machine ~]# pip freeze
argparse==1.2.1
autobahn==0.8.10
cffi==1.5.2
characteristic==14.3.0
pika==0.9.13
pyasn1==0.1.7
pyasn1-modules==0.0.8
pycparser==2.14
pycrypto==2.6.1
pyOpenSSL==0.12
pysnmp==4.2.5
requests==2.7.0
service-identity==14.0.0
six==1.7.3
Twisted==14.0.0
version-utils==0.2.2
wheel==0.24.0
zope.interface==4.1.1
If you've got the same or better versions of the relevant packages installed, I'd try a pip -vvv install --upgrade --force-reinstall cffi, just to see if there are perhaps errors that pip was masking, and go from there.
I had the same problem, following this thread https://github.com/pyca/cryptography/issues/4403, I solved the problem by reinstalling and upgrading with the command:
pip install -U cffi
You have to first remove the following packages:
cryptography
bcrypt
paramiko
Now use the following command to install:
pip -vvv install --upgrade --force-reinstall cffi
Have the same problem. After many attempts adding import cffi solve the issue.
Make sure you have cffi and cryptography installed.
You could look at the code L56 in /usr/lib/python2.6/site-packages/cffi/api.py
It needs the _cffi_backend.so in your pythonpath. You could install the python-cffi for it. But not sure whether it is in your RPM repo, especially you are using RHEL-5.
Here is an RPM for CENTOS http://cbs.centos.org/koji/rpminfo?rpmID=20613
Hope it helps. I am still searching the source code for building the _cffi_backend.so.
For me there was no way to install cffi on python3.8 because of this:
ImportError: cannot import name 'sysconfig' from 'distutils' (/usr/lib/python3.8/distutils/__init__.py)
Somehow, the package python3-distutils does not exist in Ubuntu 16.04.
So I ended up installing python3.7 and now I finally could install cffi, fixing the problem mentioned by the TS.
You should install cffi via pip install cffi
to get the latest version. I had to restart my application for it to recognize the cffi installation.
I was getting this error while trying to get the cryptography module to work with Python 3.8 for AWS Lambda.
Adding the cffi*manylinux*.whl files to my Lambda Layer (as suggested here) worked.
The cffi module comes built in for many python distributions, but not on AWS Lambda
For AWS Lambda I was facing the same issue when running on Python3.7. When I downgraded it to Python3.6, this issue was resolved.
I think this packaged might have been present in Python3.6 version and later was removed. Adding this package while making layers for AWS Lambda might resolve the problem for Python3.7.
I encountered this issue when trying to install packages in a local directory using pip install -t . and then running python (2.7). My solution was to remove the -t and not install into a local directory.
it worked after adding " import cffi " in my application.
please refer for more details.
https://buildmedia.readthedocs.org/media/pdf/cffi/latest/cffi.pdf
Thanks to #MPlanchard, for his answer which helped identify the cause
In my case, the issue was related to python3.9, changing to python3.8 it just works well!
After many futile efforts to install the right packages, the right python versions and building the perfect layer, resorting to installing Fabric solved it for me
I got this issue running an Ansible playbook using python 3.9 under Ubuntu-18.04 in WSL2. It was sorted by doing:
sudo apt-get remove -y python3-cffi-backend
sudo apt-get install -y python3-cffi-backend

How do I install opencv using pip?

I need to install cv2 for a script that has been written for me. I tried pip install cv2 and pip install open_cv and got the same problem - a warning message from dist.py and complains about zlib being not found. No cv2 installed. I also tried pyopenvc and pip install opencv-python.
So, I went to the opencv site and downloaded the relevant exe. Ran it - generated a heap of subdirectories and a make file and stuff.
What do I do now?
Install opencv-python (which is an unofficial pre-built OpenCV package for Python) by issuing the following command:
pip install opencv-python
run the following command by creating a virtual enviroment using python 3 and run
pip3 install opencv-python
to check it has installed correctly run
python3 -c "import cv2"
In pip package management, there are 4 different OpenCV packages all using the same namespace, cv2. Although they are not officially supported by OpenCV.org, they are commonly used in developers' community. You could install any of them using the following command:
pip install PACKAGE_NAME
where PACKAGE_NAME can be
opencv-python (only contains main modules)
opencv-contrib-python (contains both main and contrib modules)
opencv-python-headless (same as opencv-python but without GUI functionality)
opencv-contrib-python-headless (same as opencv-contrib-python but without GUI functionality)
You should only install one of them depending on your needs. If you accidentally installed multiple of them in the same environment, you can remove them using pip uninstall before installing the correct one again.
For more details, you can refer to the project description of OpenCV on Wheels.
As of 2021, all of these 4 packages are official OpenCV projects. Source: OpenCV Website.
To Install the Current Latest version of OpenCV then use the below commands:
Use this Command:
pip install --upgrade opencv-python
If you're facing problem in above command then try this :
pip install --upgrade opencv-contrib-python
To check the version of installed OpenCV:
import cv2
print(cv2.__version__)
Simply use this for the so far latest version 4.1.0.
pip install opencv-contrib-python==4.1.0.25
For the default version use this:
pip install opencv-contrib-python
If you have a new Raspberry Pi and want to install OpenCV then this tutorial would be a good choice.
For Ubuntu/Linux users:
sudo apt install python3-opencv
As of 10/22/2019, I think the best answer is simply
conda install opencv
It appears opencv is now in the main Anaconda channel.
To see which packages (including opencv) are in the main Anaconda channel go to Anaconda Package Lists and follow the link corresponding to your python version and os version.
Everybody struggles initially while installing OpenCV. OpenCV requires a lot of dependencies in the backend. The best way to start with OpenCV is, install it in a virtual environment. I suggest that you use the Python Anaconda distribution and create a virtual environment using it. Then inside the virtual environment, you can install OpenCV using this command:
conda install -c conda-forge opencv
Please follow the command:
pip install opencv-python
then if you want to use:
import cv2
If it's not worked due to any update, please follow the documentation
Make a virtual enviroment using python3
virtualenv env_name --python="python3"
and run the following command
pip3 install opencv-python
to check it has installed correctly run
python3 -c "import cv2"
To install open_cv you can go to this website or do this,
pip install opencv-contrib-python --upgrade
pip install opencv-python
You can test it by:
C:\> python
>>> import cv2
>>> print(cv2.__version__)
'4.5.1' # your version may be a newer one
You can install opencv the normal way:
pip install opencv-python
If you are getting errors, you can do this:
pip install opencv-python-headless
Open anaconda command prompt and type in below command.
conda install -c conda-forge opencv
Once the 'Solving environment' is done. It will ask to download dependencies. Type 'y'.
It will install all the dependencies and then you are ready to code.
I recommend this for Python 3: Please install it this way with pip
pip3 install opencv-python
This will download and install the latest version of OpenCV.
You could try using below command-
pip install opencv-contrib-python
It will basically download the compatible version. If this command fails, you could upgrade you pip using below command-
python -m pip install –upgrade pip
If you need a pictorial guide, head over to Simple Steps to Install OpenCV in Windows
You can also try installing OpenCV from prebuilt binaries from the official OpenCV site.
->pip install opencv-python you can use this.
But if this code does not working then you can check python version on cmd and anaconda because they are different. So you type command in anaconda prompt and cmd, it will work. You can check this -> pip list
Open terminal
Run the following command
pip install --trusted-host=pypi.org --trusted-host=files.pythonhosted.org opencv-python.
Hope it will work.
Installing cv2 or opencv-python using pip is sometimes a problem. I was having the same problem of installing cv2 with pip. The installation wasn't a problem the problem was to import cv2 after installation. I was getting an Import Error so to fix this i import main from pip to install opencv-python. Try to run the following code in your python file then opencv-python will be installed
from pip._internal import main as install
try:
import cv2
except ImportError as e:
install(["install", "opencv-python"])
finally:
pass
I hope this will help someone
As a reference it might help someone... On Debian system I hard to do the following:
apt-get install -y libsm6 libxext6 libxrender-dev
pip3 install opencv-python
python3 -c "import cv2"
On Ubuntu you can install it for the system Python with
sudo apt install python3-opencv
if you are using Pycharm navigate settings > Project:name > Project interpreter just search the module by name(in this case OpenCV-python) and install it. worked for me
In case you use aarch64 platform with ARM64 cpu - and/or docker
On a development board on ARM64, no python-opencv version were found at all
version: NONE.
I've had to build from source. This allowed to include CUDA support.
In my case it was already available on the board but it wasn't found on the development environment.
If compiling from source is out of reach, there are Dockers
Of course compiling will take some time (few hours on ARM core), but it is worthy process to know as most open source tools can be built this way in case of issues.
I've had this problem in Google Colab, It only worked with this specific package version.
!pip install "opencv-python-headless<4.3"
There are two options-
pip install cv2
or
pip install opencv-python
Hope it helps.

Python pip not working with egg_info error [duplicate]

I'm trying to install some packages with pip.
But pip install unroll gives me
Command "python setup.py egg_info" failed with error code 1 in
C:\Users\MARKAN~1\AppData\Local\Temp\pip-build-wa7uco0k\unroll\
How can I solve this?
About the error code
According to the Python documentation:
This module makes available standard errno system symbols. The value of each symbol is the corresponding integer value. The names and descriptions are borrowed from linux/include/errno.h, which should be pretty all-inclusive.
Error code 1 is defined in errno.h and means Operation not permitted.
About your error
Your setuptools do not appear to be installed. Just follow the Installation Instructions from the PyPI website.
If it's already installed, try
pip install --upgrade setuptools
If it's already up to date, check that the module ez_setup is not missing. If it is, then
pip install ez_setup
Then try again
pip install unroll
If it's still not working, maybe pip didn't install/upgrade setup_tools properly so you might want to try
easy_install -U setuptools
And again
pip install unroll
Here's a little guide explaining a little bit how I usually install new packages on Python + Windows. It seems you're using Windows paths, so this answer will stick to that particular SO:
I never use a system-wide Python installation. I only use virtualenvs, and usually I try to have the latest version of 2.x & 3.x.
My first attempt is always doing pip install package_i_want in some of my Visual Studio command prompts. What Visual Studio command prompt? Well, ideally the Visual Studio which matches the one which was used to build Python. For instance, let's say your Python installation says Python 2.7.11 (v2.7.11:6d1b6a68f775, Dec 5 2015, 20:40:30) [MSC v.1500 64 bit (AMD64)] on win32. The version of Visual Studio used to compile Python can be found here, so v1500 means I'd be using vs2008 x64 command prompt
If the previous step failed for some reason I just try using easy_install package_i_want
If the previous step failed for some reason I go to gohlke website and I check whether my package is available over there. If it's so, I'm lucky, I just download it into my virtualenv and then I just go to that location using a command prompt and I do pip install package_i_want.whl
If the previous step didn't succeed I'll just try to build the wheel myself and once it's generated I'll try to install it with pip install package_i_want.whl
Now, if we focus in your specific problem, where you're having a hard time installing the unroll package. It seems the fastest way to install it is doing something like this:
git clone https://github.com/Zulko/unroll
cd unroll && python setup.py bdist_wheel
Copy the generated unroll-0.1.0-py2-none-any.whl file from the created dist folder into your virtualenv.
pip install unroll-0.1.0-py2-none-any.whl
That way it will install without any problems. To check it really works, just login into the Python installation and try import unroll, it shouldn't complain.
One last note: This method works almost 99% of the time, and sometimes you'll find some pip packages which are specific to Unix or Mac OS X, in that case, when that happens I'm afraid the best way to get a Windows version is either posting some issues to the main developers or having some fun by yourself porting to Windows (typically a few hours if you're not lucky) :)
It was resolved after upgrading pip:
python -m pip install --upgrade pip
pip install "package-name"
I got stuck exactly with the same error with psycopg2. It looks like I skipped a few steps while installing Python and related packages.
sudo apt-get install python-dev libpq-dev
Go to your virtual env
pip install psycopg2
(In your case you need to replace psycopg2 with the package you have an issue with.)
It worked seamlessly.
I got this same error while installing mitmproxy using pip3. The below command fixed this:
pip3 install --upgrade setuptools
Download and install the Microsoft Visual C++ Compiler for Python 2.7 from https://www.microsoft.com/en-in/download/details.aspx?id=44266 - this package contains the compiler and set of system headers necessary for producing binary wheels for Python 2.7 packages.
Open a command prompt in elevated mode (run as administrator)
Firstly do pip install ez_setup
Then do pip install unroll (It will start installing numpy, music21, decorator, imageio, tqdm, moviepy, unroll) # Please be patient for music21 installation
Python 2.7.11 64 bit used
Other way:
sudo apt-get install python-psycopg2 python-mysqldb
I had the same issue when installing the "Twisted" library and solved it by running the following command on Ubuntu 16.04 (Xenial Xerus):
sudo apt-get install python-setuptools python-dev build-essential
It's a dependency issue.
I tried running the following commands helped me sorting out the dependencies, in my case the dependency was
grpcio
pip3 install --upgrade pip
python3 -m pip install --upgrade setuptools
pip3 install --no-cache-dir --force-reinstall -Iv grpcio==1.36.1
pip3 install pulsar-client==2.7.0
remember you must have python3 installed in your system.
First try:
pip install unroll
For sure not work :)
Then Try:
pip2 install unroll
Still get error Try:
pip3 install unroll
If pip3 Worked then suggest to change configuration to use pip3 as pip because you will get a lot of issues as the modern now is Python3 = pip3 if you execute a script files.
I had the same problem.
The problem was:
pyparsing 2.2 was already installed and my requirements.txt was trying to install pyparsing 2.0.1 which throw this error
Context: I was using virtualenv, and it seems the 2.2 came from my global OS Python site-packages, but even with --no-site-packages flag (now by default in last virtualenv) the 2.2 was still present. Surely because I installed Python from their website and it added Python libraries to my $PATH.
Maybe a pip install --ignore-installed would have worked.
Solution: as I needed to move forwards, I just removed the pyparsing==2.0.1 from my requirements.txt.
I ran into the same error code when trying to install a Python module with pip.
#Hackndo noted that the documentation indicate a security issue.
Based on that answer, my problem was solved by running the pip install command with sudo prefixed:
sudo pip install python-mpd2
For me this worked
python3 -m pip3 install -U pip
you can also try
python -m pip install -U pip
pip3 install --upgrade setuptools
WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip.
Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the underlying issue.
To avoid this problem you can invoke Python with -m pip instead of running pip directly.
Use python3 -m pip "command", eg:
python3 -m pip install --user pyqt5
I tried all of the above with no success. I then updated my Python version from 2.7.10 to 2.7.13, and it resolved the problems that I was experiencing.
That means some packages in pip are old or not correctly installed.
Try checking version and then upgrading pip.Use auto remove if that works.
If the pip command shows an error all the time for any command or it freezes, etc.
The best solution is to uninstall it or remove it completely.
Install a fresh pip and then update and upgrade your system.
I have given a solution to installing pip fresh here - python: can't open file get-pip.py error 2] no such file or directory
next installation helps me:
pip3 install cython
This worked for me:
sudo xcodebuild -license
Upgrading Python to version 3 fixed my problem. Nothing else did.
I downloaded the .whl file from http://www.lfd.uci.edu/~gohlke/pythonlibs/ and then did:
pip install scipy-0.19.1-cp27-cp27m-win32.whl
Note that the version you need to use (win32/win_amd-64) depends on the version of Python and not that of Windows.
I had this problem using virtualenvs (with pipenv) on my new development setup.
I could only solve it by upgrading the psycopg2 version from 2.6.2 to 2.7.3.
More information is at https://github.com/psycopg/psycopg2/issues/594
I faced the same problem with the same error message but on Ubuntu 16.04 LTS (Xenial Xerus) instead:
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-w71uo1rg/poster/
I tested all the solutions provided above and none of them worked for me. I read the full TraceBack and found out I had to create the virtual environment with Python version 2.7 instead (the default one uses Python 3.5 instead):
virtualenv --python=/usr/bin/python2.7 my_venv
Once I activated it, I run pip install unirest successfully.
try on linux:
sudo apt install python-pip python-bluez libbluetooth-dev libboost-python-dev libboost-thread-dev libglib2.0-dev bluez bluez-hcidump
Had the same problem on my Win10 PC with different packages and tried everything mentioned so far.
Finally solved it by disabling Comodo Auto-Containment.
Since nobody has mentioned it yet, I hope it helps someone.
I had the same problem and was able to fix by doing the following.
Windows Python needs Visual C++ libraries installed via the SDK to build code, such as via setuptools.extension.Extension or numpy.distutils.core.Extension. For example, building f2py modules in Windows with Python requires Visual C++ SDK as installed above. On Linux and Mac, the C++ libraries are installed with the compiler.
https://www.scivision.co/python-windows-visual-c++-14-required/
Following below command worked for me
[root#sandbox ~]# pip install google-api-python-client==1.6.4
Methods to solve setup.pu egg_info issue when updating setuptools or not other methods doesnot works.
If CONDA version of the library is available to install use conda instead of pip.
Clone the library repo and then try installation by pip install -e . or by python setup.py install
upgrading python's version did the work for me.
I have just encountered the same problem when trying to pip install -e . a new repo. I did not notice that the contents of setup.py haven't been saved properly and I was effectively running the command with an empty setup.py.
Hence you may experience the same error message if the setup.py of the target package is either empty or malformed.
I solved it on Centos 7 by using:
sudo yum install libcurl-devel

Install library / package in python

I'd like to install python bayesian_changepoint_detection, but I can't find instructions for how to install:
https://github.com/hildensia/bayesian_changepoint_detection
I tried
conda install bayesian_changepoint_detection
and
pip install bayesian_changepoint_detection
but it didn't work. Do you know how I should install it? My OS is Ububntu 14.04 LTS. Thanks.
You need to use the install from Github::
pip install git+git#github.com:hildensia/bayesian_changepoint_detection.git
or
pip install git+https://github.com/hildensia/bayesian_changepoint_detection.git
Looking at the content of the package in Github, I see setup.py, which means, that this module should be installed from terminal(after you've downloaded the package), like so:
python setup.py install

install HDF5 and pytables in ubuntu

I am trying to install tables package in Ubuntu 14.04 but sems like it is complaining.
I am trying to install it using PyCharm and its package installer, however seems like it is complaining about HDF5 package.
However, seems like I cannnot find any hdf5 package to install before tables.
Could anyone explain the procedure to follow?
I found that installing the libhdf5-serial-dev with
sudo apt-get install libhdf5-serial-dev
did the trick.
Search for the HDF5 library in the ubuntu package repository.
apt-cache search hdf5
The command will show the packages relating to hdf5.
install the relevant package to you.
sudo apt-get install package-name.
mostly you have to install the hdf5-tools, h5utils, python-tables.
Try to install libhdf5-7 and python-tables via apt
To be more precise, do two steps on Ubuntu
1) install hdf5
sudo apt-get install libhdf5-serial-dev
2) install pytables
pip install tables

Categories