Python extensions and maya 2012 - python

When I follow this link to install numpy my Autodesk maya 2012. I know maya 2012 has own python interpreter version 2.6.4 so that I installed numpy 1.7.1, Python 2.6 version.
import sys
sys.path.append("C:/Python26/Lib/site-package/numpy")
sys.path.append("C:/Python26/Lib/site-package/numpy/lib")
import numpy
# Error: ImportError: No module named numpy #
sys.path.append("C:/Python26/Lib/site-package")
import numpy
# Error: ImportError: No module named numpy #
After I follow this instruction, and execute commands at the python interpreter, It causes an error. However, It has already applied on the python 2.6 standalone. How to apply extensions on the maya interpreter?

You might find this link helpful: http://animateshmanimate.com/2011/03/30/python-numpy-and-maya-osx-and-windows/
It might also be possible to do it via easy_install although (like so much of maya python) there are some catches, as detailed in this question: How can I install Python modules programmatically / through a Python script?

Related

Python Error 99 while integrating Amibroker with Python

I am trying to integrate Amibroker 6.41 (64-bit) with Python. Currently, I have Python 3.11.1 (64-bit) stand-alone installed along with NumPy, and pandas installed using pip in the python library.
I have installed AmiPy.dll into the Amibroker plugin folder and Amibroker acknowledged its presence.
Need your advice on the following error received while trying to set up cointegration afl using python.
Error 99. Error occurred during Python execution: *ModuleNotFoundError: No Module named '_ctypes' *callback:
It seems to me that it is unable to import the following:
from ctypes._endian import BigEndianStructure, LittleEndianStructure
from ctypes._endian import BigEndianUnion, LittleEndianUnion
On further investigation, it seems that somehow my latest Python 3.11.1 doesn't have ctypes installed. Hence the AmiPy Dll is unable to import the above files.
Unable to decide what should be my next step to resolve this issue.
Finally solved the issue by uninstalling Python 3.11.1 and installing Python 3.10.8 as Python 3.11.1 is broken. The issue is highlighted in the bug report on GitHub (link given below)
So suggest all not to install or use Python version 3.11.1 due to DLLs not being added to sys.path in embedded startup on Windows.
[[1]: https://github.com/python/cpython/issues/100320][1]

Not able to import Tkinter in Maya 2014

I am using windows 7 and Autodesk Maya 2014.When i am trying to import Tkinter i am getting error.please tell me how to solve error given below ?
How to install any python package in Auto desk Maya 2014 ?
import Tkinter
Error
Error: line 1: ImportError: file C:\Program Files\Autodesk\Maya2014\Python\lib\lib-tk\FixTk.py line 65: DLL load failed: %1 is not a valid Win32 application
I added a few Python modules to Maya with the "addsitedir-trick" explained at the end but not every python module will be playing nicely with Maya.
Python on Windows is built with Visual Studio 2008 Professional. Maya uses it's own Python interpreter but Autodesk builts Maya with another Visual Studio version. This can lead to problems if you insall python modules and try to use them with Maya. Beatuifully explained here (together with a the hard solution of compiling the wanted modules yourself):
http://p-nand-q.com/python/building-python-27-with-vs2010.html
What you can try: Install Python 2.7 on your Windows-box, install the module you want to access in Maya (eg with pip). Now in Maya add your system SitePackages (where you just installed the module to) to your Maya-Python-Interpreter SitePackages like so:
import site
site.addsitedir("/path/to/your/python27/Lib/site-packages")
Even cleaner solution would be to use a virtualenv instead of the global site-packages folder! (That's at least what i have done to get psycopg2 and requests play with Maya)
But as mentioned in the beginning of this answer there is a possibility that this may fail (with strange errors).
By the way: I highly recommend to use pyside instead of Tkinter if you want to do GUI stuff in Maya. Or the Maya-Wrappers preferably via pymel. (http://help.autodesk.com/cloudhelp/2017/ENU/Maya-Tech-Docs/PyMel/ui.html)

Pythonnet error: dynamic module not initialized properly

I have Windows 7 x64 and a Python version 2.7.6 on win32.
The framework installed are:
Microsoft .NET Framework 4.5.2
Microsoft .NET Framework 4 Multi-Targeting Pack.
So, when I run my application he crashs on:
import clr
with this error:
SystemError: dynamic module not initialized properly
I have also rebuild pythonnet with Visual C# 2010 express, with x86 platform, but nothing.
Can anyone help me, please.
And possibly can anyone tell me the required .NET Framework installed for use pythonnet.
I had this behavior too. I fixed it by installing Python.net via pip:
python -m pip install pythonnet (might need to run as Administrator/root)
After installation completes you should not get any error when executing
> python
> import clr
The error happens because of that your clr.pyd cannot find the Python.Runtime.dll. Basically You have already import the clr.pyd successfully, but Your the clr.pyd cannot find the Python.runtime.dll. So in order to make your dll searchable, you need to add the location of your Python.Runtime.dll into the System PATH.
Let's say you have your main.py which import clr and your clr.pyd and Python.Runtime.dll in the same directory, you will just need to add the below few lines at the beginning of your main.py:
import sys
import os
sys.path.insert(0, os.path.abspath('./')) # add the current file location to sys path so that the clr module is searchable

VTK installation Python : Canopy

I have installed VTK on Canopy but when I try to run a VTK Python program, it throws me Error:
import vtkpython
ImportError: No module named 'vtkpython
Can Someone tell me Why I am getting this error.
To use VTK's python wrapper, import vtk, not "vtkpython".
Better yet, use tvtk or Mayavi's mlab interface rather than using the "raw" vtk library directly.
Otherwise, using VTK is going to feel very "unpythonic".

Using Module for different python version

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.

Categories

Resources