Python Module 'shader': from shader import ShaderProgram, ShaderCode - python

I'm trying to run a python application from source, and it has:
from shader import ShaderProgram,ShaderCode
I don't know what to download + install to get 'shader'. It's pretty unspecific and can't find the answer anywhere, anyone know what module this is?
This is a python / pyqt application.

If the program you're looking at is Inkspot (and it looks like that, since it's basically the only google hit besides this question for "from shader import ShaderProgram,ShaderCode"), shader is another module belonging to the program, not an external dependency. See the source of shader.py here.

I believe the application you're looking for is PyOpenGL.

Related

Can't import modules in Python

I'm having a hard time trying to import modules created inside a project.
The structure of my project is as follows:
myapp/calcs/__init__.py
myapp/calcs/calculations.py
myapp/tests/__init__.py
myapp/tests/test_calcs.py
Inside test_calcs.py, I have the following import statement:
from calcs import calculations as clc
However, I am getting this error:
ModuleNotFoundError: No module named calcs
I can't understand why I am having this error as I have included an init.py file inside calcs which should make it act as a module.
I also found this part of python extremely confusing. You basically need to make your project an installable package and do an editable install of it in your environment to import your modules this way. I would recommend this youtube video for a great walkthrough on the process, you only need to watch 2:36-8:36 for this topic specifically but the whole video is quite useful. Best of luck.
The first three answers in this thread describe how you can solve this pretty well!
Short version:
change from calcs import calculations as clc to from ..calcs import calculations as clc
start a terminal session in the parent folder of myapp
run python -m myapp.tests.test_calcs.py

Nuitka error Cannot find ' ' in package ' ' as absolute import

I'm trying to use the nuitka tool to turn my python program into executable on ubuntu. It works fine if the program doesn't have any import statements but breaks when I use it on a program that imports something e.g.
test.py
import numpy
print "hello, world."
type this on commandline
nuitka --recurse-all --python-version=2.7 test.py
and gives me these errors
Nuitka:WARNING:/usr/lib/python2.7/dist-packages/numpy/numarray/functions.py:45: Cannot find 'copyreg' in package 'numpy.numarray' as absolute import.
Nuitka:WARNING:/usr/lib/python2.7/dist-packages/numpy/distutils/npy_pkg_config.py:11: Cannot find 'configparser' in package 'numpy.distutils' as absolute import.
Nuitka:WARNING:/usr/lib/python2.7/dist-packages/numpy/distutils/system_info.py:1765: Cannot find 'Numeric' in package 'numpy.distutils' as absolute import.
Nuitka:WARNING:/usr/lib/python2.7/dist-packages/numpy/distutils/system_info.py:1770: Cannot find 'numarray' in package 'numpy.distutils' as absolute import.
Nuitka:WARNING:/usr/lib/python2.7/dist-packages/numpy/f2py/diagnose.py:48: Cannot find 'numpy_distutils' in package 'numpy.f2py' as absolute import.
Nuitka:WARNING:/usr/lib/python2.7/dist-packages/numpy/f2py/diagnose.py:87: Cannot find 'numpy_distutils.command.build_flib' in package 'numpy.f2py' as absolute import.
I don't know about your particular use case but I also faced similar Cannot find '' in Package errors when using nuitka.
I was using sqlalchemy and had a similar issue with configparser.
After about a day of debugging I found out that Nuitka trips up with SWIG (Dynamically Loaded shared objects).
What it means basically is, some programs/modules try to increase compatibility by using conditional imports.
For eg:
If python_version==3.5:
import thislibrary
else:
import thatlibrary
specifically the configparser library is named configparser in python3 and ConfigParser in python2.
So what basically is happening is that nuitka is trying to import python 3 stuff when you clearly are using python 2.
For me the fix was to modify the source code of sqlalchemy and change the if else construct to:
import thatlibrary
You can find more information in this Guide
written by Tom Sheffler
Official answer from Nuitaka.
What problem you facing same like another problem one user facing package 'matplotlib' as absolute import. this problem, then there nuitaka given comments below check if it useful for below comment.
I think you might be using 32 bits Python on Windows and hit the 2GB RAM boundary. Use 64 bits for better luck. Incidentally I am working on scalability improvements for the next releases which ought to make this not happen. For now Nuitka loads all say 1000 modules into RAM and compiles them all globally. Needs a lot of RAM.

How to create python Ply lex passing a module

I'm trying to use a Logo Language Compiler that uses Ply into the Unity3D environment for an Open Source project https://github.com/ssouzawallace/blocks-programming.
To do so I am using IronPython that is a Python interpreter running in .NET (I need this to run in Uinty3D). There is a bug in IronPython and i found others with the same issue related to the traceback of python script execution.
In resume if I run the Logo Compiler using the official Python interpreter everything goes OK. But in IronPython, when the code pass trough the get_caller_module_dic method it cannot find my pyLex stuff because it cannot reach the second frame level.
In order to resolve the problem I am wondering to pass the proper object or module to the method:
def lex(module=None,object=None,debug=0,optimize=0,lextab="lextab",reflags=0,nowarn=0,outputdir="", debuglog=None, errorlog=None):
But I don't know how to do this.
Someone know what can I do?
Thank you very much in advance
Found solution here Python: How do I get a reference to a module inside the module itself?
Now I pass the entire script as a module instead hoping the lex and yacc script find my module using the traceback.
Using
import sys
current_module = sys.modules[__name__]

Python - How do you import downloaded directories/modules?

This is the first time I have attempted to use anything other than what's provided by python.
I have recently gotten into pythons provided Tkinter, though due to some issues I decided to use another GUI, and heard that PyQt was highly recommended, so I downloaded that and looked into various tutorials. In these tutorials, I cannot seem to execute any of the import statements in said tutorials that relate to PyQt, primarily PyQt5 (I have checked I have the correct version number by the way).
So for instance:
import PyQt5
raises the error:
Traceback (most recent call last):
File "/Users/MEBO/PycharmProjects/Music/testing.py", line 1, in <module>
import Qt
ImportError: No module named 'Qt'
[Finished in 0.1s with exit code 1]
I have a lot of research into this. I've heard people talk of using pip to install modules, and I have done this be safe (as well as downloading it from the internet), I've tried changing the project interpreter to versions Python3/ 2.7/ 2.6, appending the path name to the sys.path directory, (which I really know nothing about to be honest, I was hoping I'd get lucky), though nothing seems to work.
Are you supposed to be able to just import a module off the bat, or do you have to set some things up first?
For windows download the package and extract it to (path where python installed)\Python27\Lib and then try to import.
Specific to PyQt
This package cannot just be downloaded and imported, it must be built because it is not pure python, it uses Qt (C++) and requires dependancies. Read this tutorial on installation.
There is also a very complete python package distribution, Anaconda, that includes pyqt and much more. Almost all the packages I ever looked at are in there.
In general to pure python code
In other cases, if you place modules/code that has been download into the directory that your python script is run from, you can import off the bat, or you can append/insert any folder to the sys.path.
# importer will search here last
sys.path.append('/path/to/code/')
# importer will search here second, right after script's directory
# this can be useful to override a module temporarily...
sys.path.insert(1,'/path/to/code/')

Error on connecting to python libraries

I have a project that has code which will communicate with a python script and call python functions. In the proj file, i've added the includePath for the python header files, and added external python library to the project (python27.a). However the qt compiler gave me an error:
No rule to make target
/home/pgeng/work/OpenModelica-rev.9876.CSA/OMEdit/OMEditGUI/../../../../../../usr/lib/python2.7/libpython2.a
, needed by ../bin/OMEdit. Stop
What does this mean? How can i fix it? this is anything related to PyQt?
It seems like libpython2 is missing.
You will have to :
Find out what package provides this library.
You can Google for that.
Or search a repo for the lib.

Categories

Resources