In Julia I am using the module PyCall
using PyCall: #pyimport
When I then try to use the scikitlearn library's module called ensamble, there is no problem, it works and I can use the module:
#pyimport sklearn.ensemble as skle
However when I try to do the same with the PIL library or PIL library's module Images, it doesn't work.
#pyimport PIL.Image as PILI
I get the following error: ERROR: PyError (:PyImport_ImportModule)
ImportError('No module named PIL.Image',)
[inlined code] from /home/lara/.julia/v0.4/PyCall/src/exception.jl:81
in pyimport at /home/lara/.julia/v0.4/PyCall/src/PyCall.jl:387
Can someone please talk me through the steps to get this working becasue I don't see how this is different from the scikit learn library and ensamble module.
Based on discussion in the comments, the issue appears to be that PyCall is using its own Python installation which does not have the requisite library installed. There are two options:
follow these instructions to change the Python installation referenced by PyCall to your local one in /home/lara/anaconda2.
use Conda.jl to add PIL to the Conda.jl Python install:
Conda.add("Pillow") (you could probably use PIL, but Pillow is a compatible fork that is actively maintained from what I can tell)
The second option is probably slightly preferred, but if you have many packages installed already it may be simpler to try the first option (you can always switch back to the Conda.jl version if something doesn't work).
Related
I want to use OpenCV on Julia, then I tried to use PyCall.
I made my Python environment by pyenv, therefore, I tried below commands;
julia> ENV["PYTHON"] = "/Users/MYNAME/.pyenv/shims/python"
julia> using Pkg
julia> Pkg.add("PyCall")
Then, I tried a below command and this error message was returned.
julia> using PyCall
ImportError: No module named site
This error message is too short to infer causes.
Anyone knows the causes and how to solve?
PyCall is tested with Anaconda and it works best with the Anaconda installation inbuilt into Julia.
using Pkg
#ENV["PYTHON"] = ""
pkg"add PyCall"
#pkg"build PyCall" #required to restore the default config if you changed it
pkg"add Conda"
using Conda
Conda.runconda(`install -c conda-forge opencv`)
using PyCall
const cv = pyimport("cv2")
Now you are ready to do your work.
There are also Julia bindings for OpenCV, although they haven't been integrated with Julia's artifact system and so still require a certain amount of manual effort to install. To get started, see this blog post.
Question:
I want to compile a third-party library like Pillow or Numbpy but I want to change the name of the python27.dll to corepython27.dll. How do I do this during the compile process? Is it something I need to change in the setup.py? Or the distutils library?
I should explain that I have no experience in compiling at all. I just know that I will need to make this change as I learn more about the basics of compiling.
Explanation:
Corel's PaintShop Pro uses an embedded python interpreter to run scripts inside the program. And I would like to be able to use third-party libraries like pillow and numpy but they always fail to load. The version of python that is included with PaintShop Pro is 2.7.5. I've made sure to download the appropriate versions of these libraries but it always fails with a "DLL module doesn't exist" type error.
Using a PE viewer I was able to see that other libraries like TKinter were using imports corepython27.dll instead of python27.dll like pillow was.
Also pillow for 2.7 was using msvcr90.dll but the custom version of the tkinter library included with PSP was compiled with msvcr110.dll. Do you think this will be an issue? Do I need to compile pillow with the appropriate version of msvcr DLL? Or is matching versions (2.7) and making sure it uses the correct python.dll (corepython27.dll) the only important thing?
You can create a symbolic link named corepython27.dll showing to the installed python27.dll. You can do this in your console via the command
MKLINK <path_to_corepython.dll> <path_to_python27.dll>
I am getting these errors trying to run a python3 program in itelliJ IDEA on a mac.
import numpy as np
ModuleNotFoundError: No module named 'numpy'
from PIL import Image, ImageChops
ModuleNotFoundError: No module named 'PIL'
from skimage.feature import match_template # requires numpy, scipy, and six
ModuleNotFoundError: No module named 'skimage'
All of these modules have been successfully installed using pip3. I have confirmed the installs using IDLE. Clearly, it seems, there is more to it than simply installing, but I don't know what it is.
I cannot find anything that addresses concerns on python.org. They, in fact, refer me to Stackoverflow. The closest I found here dealt with numpy and python2.7 on mac. There are no responses to that one.
Look in the Preferences for the Project Interpreter setting, and make sure it's pointing to the right python version.
Secondly, since you're already using and IDE use PyCharm. It's IntelliJ's python specific IDE, and it'll have better documentation on python specific technical problems.
The default version of python (ie, one that opens on typing "python" in command line) is 2.6 on my server. I also have 2.7 installed. How do I import a module, in this case numpy, in python2.7? When I try to import right now, it gives me an error -
ImportError: No module named numpy
Is there any workaround, apart from downloading the package and doing a build install?
I agree with the comment above. You will have to compile it separately. I once tried a hack of importing and modifying the sys.path however I ran into issues with the .so files.
Where can i get OpenCV for python?What are the pre-requisites?? i tried to install opencv-python through synaptic package manager but Python says
No module named CVtypes
CVTypes is a third party implementation that essentially wraps python around objects written in C, the language that OpenCV is written in (along with C++). If you want to use that, you will have to download and install it separately, as it is not part of the standard repositories of Ubuntu's Synaptic package manager that I know of at this time (I assume you are on Ubuntu because you mentioned 'Synaptic', Ubuntu's package manager).
However, there is an official python interface for OpenCV that is included in the OpenCV SVN repository and build packages. When installing version 1.0 from the package manager in Ubuntu, the python modules will be installed in the following directory:
/usr/lib/pymodules/python2.6/opencv
Ensure that is part of your PYTHONPATH environment variable and you should be able to import the modules as such:
from opencv.cv import *
from opencv.highgui import *
OpenCV over time has accumulated numerous Python bindings, mostly due to the strange way arrays are represented in OpenCV (IMHO). Here is a short list:
PyOpenCV
Scikits Image
Ctypes OpenCV
SWIG OpenCV
Choose which one you want to use and keep it consistent and upto date. I personally prefer the classic WillowGarage version[listed last] over its fancier cousins since it has most development and test muscle behind it.
get it from here unofficial binary packages.
by the way, they provide unofficial packages for many other projects
Tried the official website? http://opencv.willowgarage.com/wiki/Welcome
check your openCV version. Version 2 needs a simple
import cv
you may have a look at the samples/python folder.
this webpage explains in great depth on the installation
http://opencvpython.blogspot.com/2012/05/install-opencv-in-windows-for-python.html
after the installation try out the samples provided by opencv\samples\python2