Another of my queries about an embedded Python 2.7.3 interpreter on Windows. I need to install numpy and matplotlib as support packages for an embedded interpreter in a C++ program compiled in Visual Studio 2010.
Some background:
I've been trying to make this work for a few months. The main issue is that numpy for Python 2.7 is compiled against an earlier version of the MS C library (VS2008) whereas my application is compiled against the 2010 version (a fact beyond my control - that is the office compiler).
I worked around this by fiddling with the manifest for my application to let it load the correct C library for numpy and this got it to import. As an end-user has tried out new features, bugs have started to appear, including untraceable crashes.
My current state:
I pinned some of these down to a poor compilation on my part of the Python 2.7.3 source, in particular the dependencies (lots of the crashes seemed associated with Tkinter from matplotlib). So I started afresh on the Python compilation and now have a clean compiled version of all the core and dependencies of Python 2.7.3. Now I'm looking at numpy/matplotlib.
My questions
Is it worth attempting to compile numpy against VS2010 or is my earlier manifest mangling solution the only way?
If the former, what problems might I encounter in doing so (i.e. what should I watch ou for)?
In the latter, how do I get numpy to install in the lib/site-packages folder of my embedded intepreter?
use cygwin to build numpy on windows.
I am on windows-xp
Its working fine for me.. .!
In cygwin python2.6 comes as a default python. I have installed python2.7 but not installed numpy in python2.7.
To use it on python2.7 i have run python2.7 setup.py build
You can see that in screen-shot of my terminal. and in folder 'namit' i have placed 'numpy' dir that i have compiled on cygwin.
when i have imported numpy when i am in that dir.. it worked...you can see that in globals() from where it has imported.
Related
Working on python 2.7(not anaconda). Operating system Windows server 2012 R2
The pypi installation mentions two fixes for this, installing Visual C++ redistributable 2015 and Universal C Runtime.
As well as a manual fix for older anaconda versions, which is for python3(I am not using anaconda version, and also my python version is 2.7 so presuming it doesn't apply in my case)
link here:
https://pypi.org/project/opencv-python/
installed both the dependencies but couldn't get it to work.
Any ideas on how I may fix this?
Since Python 2.7 is still supported, this could be the possible solution.
Installing OpenCV from prebuilt binaries:
Below Python packages are to be downloaded and installed to their default locations.
Python-2.7.x
Numpy
Matplotlib
Install all packages into their default locations. Python will be installed to C:/Python27/.
After installation, open Python IDLE. Enter import numpy and make sure Numpy is working fine.
Download latest OpenCV release and install it : Latest OpenCV-build
Goto opencv/build/python/2.7 folder.
Copy cv2.pyd to C:/Python27/lib/site-packeges.
Open Python IDLE and type following codes in Python terminal.
import cv2
print cv2.__version__
I'm using Python 2.7, Windows 7, and Keras 1.2.1 (Keras2 seems to be having a lot of compatibility issues with different PC/Python configs, so I was recommened to use 1.2.1)
I'm using a script from Practical Deep Learning For Coders, Part 1 Course
import utils; reload(utils)
from utils import plots
The error I"m getting is as below
Problem occurred during compilation with the command line below:
"g++" -shared -g -DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION -m64 -DMS_WIN64 -I"c:\python27\lib\site-packages\numpy\core\include" -I"c:\python27\include" -I"c:\python27\lib\site-packages\theano\gof" -L"c:\python27\libs" -L"c:\python27" -o C:\Users\Moondra\AppData\Local\Theano\compiledir_Windows-7-6.1.7601-SP1-Intel64_Family_6_Model_94_Stepping_3_GenuineIntel-2.7.12-64\lazylinker_ext\lazylinker_ext.pyd C:\Users\Moondra\AppData\Local\Theano\compiledir_Windows-7-6.1.7601-SP1-Intel64_Family_6_Model_94_Stepping_3_GenuineIntel-2.7.12-64\lazylinker_ext\mod.cpp -lpython27
I can't decipher what this means. Google search brought up a Chinese message board.
It seems to be a g++ problem as the previous warning I got was as follows:
WARNING (theano.configdefaults): g++ not available, if using conda:conda install m2w64-toolchain``. Despite installing m2w64-toolchain afterwards, I was continuing to get the same warning.
Some interesting things I learned while trying to configure theano and keras:
C++/g++
Depending on your python version, you have to install a corresponding version of the C++ compiler, or Visual Studio. Ex: Python 2.7 needs C++ 9.0 (Visual Studio 2008). But Python 3.5 needs C++ 14.0 (Visual Studio 2015) -- See here for more: https://wiki.python.org/moin/WindowsCompilers
I also had to install MinGW for g++ compilers: https://nuwen.net/mingw.html
Even with it correctly installed, you may see an error about hypot. This question shows two possible solutions: g++ error on import of Theano on Windows 7
I tried installing everything via Conda, but all calculations were slower than continents moving away from each other. Then I gave up conda and installed everything via standard python. (First python, then numpy, then scipy, then theano, then keras). Not sure if MinGW goes before of after numpy/scipy, but I think it goes before.
BLAS/LAPACK
Numpy and theano may warn you that no lapack/blas is installed. For that, I used the numpy and scipy libraries available here, they're great and fast: http://www.lfd.uci.edu/~gohlke/pythonlibs/
Another option is installing MKL directly from Intel, before installing numpy and scipy.
Path problems / Invalid Token - ldflags
Avoid installing anything, including the MKL, in folders containing spaces in their names! That will definitely confuse theano/numpy.
You may get "invalid token" errors if you have spaces in folders, and a ldflags var described in that error. To solve that, either reinstall your mkl libraries in folders without spaces, or configure the .theanorc file in the theano home folder with your [blas] configuration and the ldflags var. (See here: Receive AssertionError while optimizing convolution in theano)
Since I wasn't willing to reinstall MKL in another folder, I learned to create symbolic links to windows. (in the answer above)
Replace the folders with space in the theano config and also in the numpy config files (__config__.py), you can see its content with np.__config__.show(). (See answer above)
I solved the problem.
I reinstalled Anaconda.
And then via command line I wrote conda install m2w64-toolchain
This time I didn't get a message stating that m2w64 was already installed. I'm assuming it was a path issue and this time reinstalling everything from the start also created a new path?
I have searched around entire internet.
1. i have 64bit 2014 maya installed, i had 32bit python installed at c:\python27.. as you know maya installs its own python and works with that, i want to change it and make maya work with my own python that is installed in c drive.
What i did?
1. i did change the python, first unisntalled and and then installed 64bit version, i copied cv2.pyd to its site-packages and also installed matplotlib,scipy, pandas, numpy. my code in pycharm works just fine but maya gives error.
2. i changed mayas python path environment but still maya is using its own installed python not pointing to mine.
import sys
print sys.platform
print sys.version
print sys.prefix
print sys.path
in maya tells me that its using python 2.7.3 whereas the python i want to point which is in c drive is 2.7.8.. anything ? how can i make maya work with the other python
Maya's version of Python (mayapy) is compiled with Visual Studio 2010, Python's 2.7.x standard distribution is compiled with VS2008, and the two aren't compatible. So packages you install via pip in your standard 64 bit Python install won't work with Maya if they have binary dependencies. (ex numpy, scipy, PIL, pandas, etc...)
To test, open a python tab in the script editor and do this:
import sys
print (sys.version)
# Result: 2.7.3 (default, Aug 1 2012, 16:33:56) [MSC v.1600 64 bit (AMD64)] #
The part that matters here is in square brackets [MSC v.1600 64 bit (AMD64)].
If you do the same in your installed version of Python 2.7.x, you'll see that they won't match.
What you'll need to do is to compile these modules yourself using Visual Studio 2010 + either mayapy or a version of Python specifically built with VS2010. Either way it won't be easy in some cases.
I've made builds of packages I use compatible with Maya 2014-2015-2016 available here. Extract those packages anywhere Maya can see python packages and you should be able to work.
Side note: Maya on OSX doesn't suffer from these compatibility issues.
I recently started working on a project using just vim as my text editor with a virtualenv setup. I installed a few API's on this virtualenv from GitHub. Eventually, the project got a little bigger than vim could handle so I had to move the project to an IDE.
I chose Aptana Studio 3. When I started up Aptana, I pointed the project directory to the virtualenv folder that I had created to house my project. I then pointed the interpreter at the Python executable in App/bin (created from virtualenv)/python2.7. When I started reworking the code to make sure I had everything mapped correctly, I was able to import the API's that I had installed just fine. CherryPy came through with no problems, but I've been having an issue with importing a module that I believe is part of the stdlib--urlparse. At first, I thought it was that my python interpreter was 2.7.1 rather than 2.7.5 (I found the documentation in the 2.7.5 section with no option to review 2.7.1), but my terminal is using 2.7.1 and is able to import the module without any errors (I'm using OSX, Mountain Lion). I am also able to import the module when I activate the virtualenv and run my python interpreter. But when I plug "from urlparse import parse_qsl" into Aptana, I'm getting an error: "Unresolved_import: parse_qsl".
Should I have pointed this at a different interpreter and, if so, will I need to reinstall the API modules I had been working with in the new interpreter?
Update: I finally ended up restarting the project. It turns out that not all of the standard Python tools are selected when you select the virtualenv interpreter. After I selected all of the python tools from the list (just after choosing the interpreter), I was able to get access to the entire standard library.
Do NOT just import the modules into your project. Many of the stdlib modules are interdependent and the import function will only import a module into your main project directory, not a libary!
I'm trying to test my scipy install by installing nose and entering
import scipy
scipy.test('1','10')
I get some 200 errors but one of the more common is:
.... No module named msvccompiler in numpy.distutils; trying from distutils
Missing compiler_cxx fix for MSVCCompiler
I have MS Virtual Studio 2009 installed (required for python 2.7)
Can anyone help me eliminate that error or tell my why I can't?
Thanks
You have to do 2 things to make it find the Visual Studio Compiler:
In your environment, set VS90COMNTOOLS=%VS__vvv__COMNTOOLS% where vvv is your installed version. See other related questions on stackoverflow about setup.py and vcvarsall.bat
Run python from a Visual Studio Developer Command Prompt. VS includes a link for this in the start menu. It sets up all the environment variables you need to run the compilers and related tools from the command line.
Best solution to this could be using the Anaconda Python distribution
It has most of the engineering and data analysis packages and automatically sets path of the C++ compiler. You can easily install numpy, scipy, matplotlib etc. using Anaconda. It will not show vcvarshall.bat as well as numpy.core.multiarray error for numpy