install libsvm for python in windows - python

I tried to install libsvm downloaded from here http://www.csie.ntu.edu.tw/~cjlin/libsvm/
I already do the stepped written in the README which is
Building Windows Binaries
=========================
Windows binaries are in the directory `windows'. To build them via
Visual C++, use the following steps:
1. Open a DOS command box (or Visual Studio Command Prompt) and change
to libsvm directory. If environment variables of VC++ have not been
set, type
"C:\Program Files\Microsoft Visual Studio 10.0\VC\bin\vcvars32.bat"
You may have to modify the above command according which version of
VC++ or where it is installed.
2. Type
nmake -f Makefile.win clean all
3. (optional) To build shared library libsvm.dll, type
nmake -f Makefile.win lib
I also copied the libsvm.dll to my windows32 folder.
I cant seem to find anything wrong but when I compiled a python code with "import svm" in it, I got the following error:
$ python analyze.py
Traceback (most recent call last):
File "analyze.py", line 2, in <module>
import baseline_classifier, naive_bayes_classifier, max_entropy_classifier, libsvm_classifier
File "D:\twitter-sentiment-analyzer-master\libsvm_classifier.py", line 1, in <module>
import svm
ImportError: No module named svm

Easy way to install:
Download libsvm's install binaries from http://www.lfd.uci.edu/~gohlke/pythonlibs/#libsvm
You might want to install libsvm‑3.17.win‑amd64‑py2.7.exe or libsvm‑3.17.win32‑py2.7.exe depending upon you windows config

Related

I can't install ssdeep module for python 3.4

I currently use python 3.4 and I also try to install ssdeep module for python. My operating system is windows 8. My best option is here: (I think) https://pypi.python.org/pypi/ssdeep, then I downloaded the tar.gz file but I get an error when I use this command in the specific directory;
python setup.py install
and the error output:
error: Microsoft Visual C++ 10.0 is required. Get it with "Microsoft Windows
SDK 7.1": www.microsoft.com/download/details.aspx?id=8279
Even though I have them installed on my computer. (I could not find any .whl file of ssdeep) I can install ssdeep on a OSX without of anything needed. So what is wrong?
I am not running Windows but under Linux when you downloaded the tar.gz file you would have to extract it and then run python setup.py install in the extracted directory not pip (assuming there is a setup.py file there of course)

How do I solve the issue "No module name Botan"

I am using windows 8 and python 3.6.1 I've done the following command in my cmd:
pip install cryptoshop
However, when I run the following python code:
from cryptoshop import encryptfile
from cryptoshop import decryptfile
result1 = encryptfile(filename="test", passphrase="mypassphrase", algo="srp")
print(result1)
result2 = decryptfile(filename="test.cryptoshop", passphrase="mypassphrase")
print(result2)
I get the following error:
Traceback (most recent call last):
File "C:/Users/Owner/Desktop/test.py", line 1, in
from cryptoshop import encryptfile
File "C:\Users\Owner\AppData\Local\Programs\Python\Python36-32\lib\site-packages\cryptoshop__init__.py", line 26, in
from cryptoshop.cryptoshop import encryptfile
File "C:\Users\Owner\AppData\Local\Programs\Python\Python36-32\lib\site-packages\cryptoshop\cryptoshop.py", line 56, in
from ._cascade_engine import encry_decry_cascade
File "C:\Users\Owner\AppData\Local\Programs\Python\Python36-32\lib\site-packages\cryptoshop_cascade_engine.py", line 27, in
from ._nonce_engine import generate_nonce_timestamp
File "C:\Users\Owner\AppData\Local\Programs\Python\Python36-32\lib\site-packages\cryptoshop_nonce_engine.py", line 39, in
import botan
ModuleNotFoundError: No module named 'botan'
Now, I obviously know that you must install botan into python in order to use it. However, this is where I am running into an issue. I've downloaded Botan from this link as instructed:
https://github.com/randombit/botan
And then I've followed these instructions in an attempt to install Botan:
./configure.py [--prefix=/some/directory]
make
make install
However, when I type make into the command line I get an error saying there is no such command. And then when I go to run my above Python code I still get the no module Botan error. So obviously I am doing something run. How can I properly install Botan into my Python 3.6 directories so that I can use cryptoshop.
I've also attempted to do pip install Botan, as that is how I've installed so many other python libraries but that has been unsuccessful as well.
make is a linux command
According to the botan website you can use nmake as a replacement on windows ( http://wiki.c2.com/?UsingNmake ) :
On Windows
You need to have a copy of Python installed, and have both Python and
your chosen compiler in your path. Open a command shell (or the SDK
shell), and run:
$ python configure.py --cc=msvc (or --cc=gcc for MinGW) [--cpu=CPU]
$ nmake
$ botan-test.exe
$ nmake install
Botan supports the nmake replacement Jom which enables you to run
multiple build jobs in parallel.
source : https://botan.randombit.net/manual/building.html
For completeness, here's how I made it work on a Mac
Assuming you have brew installed.
brew install botan
You may need to install other functionality first:
brew install gmp
brew install mpfr
brew install mpc
Find out where botan got installed with brew info botan.
My location is /usr/local/Cellar/botan/2.6.0
In that folder, you'll find lib/python2.7/site-packages, copy the contents of this folder into your Python's installation site-packages folder.
Note 1: At the time of this writing, only python 2.7 seems to be supported, but I'm using python 3.6 and everything seems to be working.
Note 2: If the file is called botan2.py, you may need to rename it to botan.py in your python's site-packages folder.

opencv import failed in windows container (on Windows Server 2016)

I run the following container to test my opencv-python environment on Windows Server 2016.
docker run -i --rm python:2.7-windowsservercore
(the python:2.7-windowsservercore image is an official python image which is base on microsoft/windowsservercore)
and in the interacive console, I got the opencv-python installed by:
pip install opencv-python
after this finished, I test the opencv-python package by:
python -c "import cv2"
but I got the following error:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Python\lib\site-packages\cv2\__init__.py", line 9, in <module>
from .cv2 import *
ImportError: DLL load failed: The specified module could not be found.
then I installed python-2.7.13 on the host(not inside container), input the same pip install commands, and test python -c "import cv2" again, it won't report any error. I wonder if there are some DLL files are missing in the container? What package or software should I install in the container to fix this error?
Based on the accepted answer to this question I would put my money on you not having the required MSVC runtime. Assuming it was compiled with Visual Studio 2015 the runtime can be downloaded from Visual C++ Redistributable for Visual Studio 2015
I found the solution in this place.
Copy the following files from your host into your container's \System32 folder:
msacm32.dll
avifil32.dll
avicap32.dll
msvfw32.dll

Windows: Python + OpenCV + Qt: "import cv2" gives "dll not found" error

I have a problem when I'm trying to use OpenCV (v3.1.0) in Python (v3.4). To make things more complicated, OpenCV is built with the "contrib" package and Qt support (v5.5).
This is what I did (this has some pitfalls on it's own, but those are out of the scope of this question):
Install required software
I installed WinPython (v3.4.4, 64 Bit version)
I installed cmake (v3.6.0)
Download sources
I downloaded the Qt sources from the GIT repo
I downloaded the OpenCV sources from the GIT repo
I downloaded the OpenCV "contrib" sources from the GIT repo
build sources -> RELEASE, 64 Bit (!)
build Qt from sources
build OpenCV from sources (with "contrib" modules)
cmake ( OpenCV 3.1.0 for python 3 ) already took care of copying the "cv2.pyd" to the "your/python/folder/Lib/site-modules" directory.
Now I have the problem that calling "import cv2" from python gives the error "
>>> import cv2
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import cv2
ImportError: DLL load failed: Module not found
How can I find out which module is missing and how to solve it?
What you may not want to do is just adding paths that are likely needed to your environment variables.
There is a way to find out what is missing:
Download DependencyWalker
open your "cv2.pyd" with the dependency walker
Analyze your file (starts automatically when you select your file)
Hit "F9" such that it shows the full paths to the required DLLs
Check, which DLL files are missing
Copy them to those folders
For me, it was the case that python/cv2.pyd searched to all the Qt DLLs in the folder where cv2.pyd is in.
I just copied them there and that was it.
For Windows:
Step 1. Download python installer from https://www.python.org/downloads/
,install python by double clicking this file and check the option for adding python to PATH as in given image.
Step 2. Download file "numpy‑1.15.4+mkl‑cp27‑cp27m‑win32.whl" from unofficial site.
Go to this file's location open command prompt and type-
pip install numpy‑1.15.4+mkl‑cp27‑cp27m‑win32.whl
Now go to python IDLE and type:
import numpy
It should give no error.
Step 3. Download file "scipy‑1.2.1‑cp27‑cp27m‑win32.whl" from unofficial site.
Go to this file's location open command prompt and type-
pip install scipy‑1.2.1‑cp27‑cp27m‑win32.whl
Now go to python IDLE and type:
import scipy
It should give no error.
step 4 : Download file "opencv_python‑2.4.13.7‑cp27‑cp27m‑win32.whl" from unofficial site.
Go to this file's location open command prompt and type-
pip install opencv_python‑2.4.13.7‑cp27‑cp27m‑win32.whl
Now go to python IDLE and type:
import cv2
It should give no error, means opencv installed successfully in windows.

Python installation error: NumPy package

I am trying to follow this tutorial and getting an error when I do the following:
(DataVizProject) $ pip install -r requirements.txt
It gives me a big error log, the last few lines of which are :
C:\python\new-coder\dataviz\DataVizProj\build\numpy\numpy\distutils\system_info.
py:1422: UserWarning:
Lapack (http://www.netlib.org/lapack/) sources not found.
Directories to search for the sources can be specified in the
numpy/distutils/site.cfg file (section [lapack_src]) or by setting
the LAPACK_SRC environment variable.
warnings.warn(LapackSrcNotFoundError.__doc__)
error: Unable to find vcvarsall.bat
----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in C:\python\new-coder
\dataviz\DataVizProj\build\numpy
I know it doesn't work because when I do the following steps:
>>> import numpy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named numpy
>>> import matplotlib
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named matplotlib
>>>
Thanks a lot!
#Hasnain, when you are using python in windows, eventually you will see this error for some packages.
You have three options when it happen (in order of relevance):
1 - Try to download a MSI file. It will install the library without any problems. To numpy specifically you can download here (http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy)
2 - You can download the whole file and try a python setup.py install and modify the packacge if it raise some errors.
3 - You can compile your own library for your operational system.
Many MSI files you can find here (http://www.lfd.uci.edu/~gohlke/pythonlibs/)
The method recommended in that tutorial works well for Unix systems. If you are on Windows you will go through a lot of trouble trying to build numpy from sources with pip. I will save you some time, follow the official recomendation and try some binary install of the recommended ones in the official Scipy website. I personally recommend you the Anaconda or the Enthought distribution.
Usually when installing packages on windows, by default python searches for Visual Studio 2008 . You can either install it or use MinGW Compiler.
If you decide to use MinGW you should edit your distutils.cfg file in Python27\Lib\distutils directory :
[build]
compiler = mingw32
[build_ext]
compiler = mingw32

Categories