"from core import G"?

MakeHuman python API, python plugins, etc

Moderator: joepal

"from core import G"?

Postby 7yl4r » Fri Apr 18, 2014 3:58 pm

I'm looking to interface with the source using my own python scripts. I'm getting an error I can't make sense of, though.


Code: Select all
ImportError: cannot import name G



The error itself is no mystery... Of course core.G can't be imported, there is no such module. I downloaded the source snapshot directly from makehuman.org, am I missing a module or misunderstanding something here?

It's also worth noting that python makehuman.py fails silently for me, appearing to do nothing.
Not much more info from python -v, either.

Code: Select all
(Canopy 64bit) C:\MYFILEDIRINFO\Documents\futureMe_MakeHuman\MakeHuman\makehuman
>python -v makehuman.py
# installing zipimport hook
import zipimport # builtin
# installed zipimport hook
# C:\MYFILEDIRINFO\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.3.0.1715.
win-x86_64\lib\site.pyc matches C:\MYFILEDIRINFO\AppData\Local\Enthought\Canopy\
App\appdata\canopy-1.3.0.1715.win-x86_64\lib\site.py
import site # precompiled from C:\MYFILEDIRINFO\AppData\Local\Enthought\Canopy\A
pp\appdata\canopy-1.3.0.1715.win-x86_64\lib\site.pyc
# C:\MYFILEDIRINFO\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.3.0.1715.
win-x86_64\lib\os.pyc matches C:\MYFILEDIRINFO\AppData\Local\Enthought\Canopy\Ap
p\appdata\canopy-1.3.0.1715.win-x86_64\lib\os.py
import os # precompiled from C:\MYFILEDIRINFO\AppData\Local\Enthought\Canopy\App
\appdata\canopy-1.3.0.1715.win-x86_64\lib\os.pyc
import errno # builtin
import nt # builtin
# C:\MYFILEDIRINFO\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.3.0.1715.
win-x86_64\lib\ntpath.pyc matches C:\MYFILEDIRINFO\AppData\Local\Enthought\Canop
y\App\appdata\canopy-1.3.0.1715.win-x86_64\lib\ntpath.py
import ntpath # precompiled from C:\MYFILEDIRINFO\AppData\Local\Enthought\Canopy
\App\appdata\canopy-1.3.0.1715.win-x86_64\lib\ntpath.pyc
# C:\MYFILEDIRINFO\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.3.0.1715.
win-x86_64\lib\stat.pyc matches C:\MYFILEDIRINFO\AppData\Local\Enthought\Canopy\
App\appdata\canopy-1.3.0.1715.win-x86_64\lib\stat.py
import stat # precompiled from C:\MYFILEDIRINFO\AppData\Local\Enthought\Canopy\A
pp\appdata\canopy-1.3.0.1715.win-x86_64\lib\stat.pyc
# C:\MYFILEDIRINFO\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.3.0.1715.
win-x86_64\lib\genericpath.pyc matches C:\MYFILEDIRINFO\AppData\Local\Enthought\
Canopy\App\appdata\canopy-1.3.0.1715.win-x86_64\lib\genericpath.py
import genericpath # precompiled from C:\MYFILEDIRINFO\AppData\Local\Enthought\C
anopy\App\appdata\canopy-1.3.0.1715.win-x86_64\lib\genericpath.pyc
# C:\MYFILEDIRINFO\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.3.0.1715.
win-x86_64\lib\warnings.pyc matches C:\MYFILEDIRINFO\AppData\Local\Enthought\Can
opy\App\appdata\canopy-1.3.0.1715.win-x86_64\lib\warnings.py
import warnings # precompiled from C:\MYFILEDIRINFO\AppData\Local\Enthought\Cano
py\App\appdata\canopy-1.3.0.1715.win-x86_64\lib\warnings.pyc
# C:\MYFILEDIRINFO\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.3.0.1715.
win-x86_64\lib\linecache.pyc matches C:\MYFILEDIRINFO\AppData\Local\Enthought\Ca
nopy\App\appdata\canopy-1.3.0.1715.win-x86_64\lib\linecache.py
import linecache # precompiled from C:\MYFILEDIRINFO\AppData\Local\Enthought\Can
opy\App\appdata\canopy-1.3.0.1715.win-x86_64\lib\linecache.pyc
# C:\MYFILEDIRINFO\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.3.0.1715.
win-x86_64\lib\types.pyc matches C:\MYFILEDIRINFO\AppData\Local\Enthought\Canopy
\App\appdata\canopy-1.3.0.1715.win-x86_64\lib\types.py
import types # precompiled from C:\MYFILEDIRINFO\AppData\Local\Enthought\Canopy\
App\appdata\canopy-1.3.0.1715.win-x86_64\lib\types.pyc
# C:\MYFILEDIRINFO\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.3.0.1715.
win-x86_64\lib\UserDict.pyc matches C:\MYFILEDIRINFO\AppData\Local\Enthought\Can
opy\App\appdata\canopy-1.3.0.1715.win-x86_64\lib\UserDict.py
import UserDict # precompiled from C:\MYFILEDIRINFO\AppData\Local\Enthought\Cano
py\App\appdata\canopy-1.3.0.1715.win-x86_64\lib\UserDict.pyc
# C:\MYFILEDIRINFO\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.3.0.1715.
win-x86_64\lib\_abcoll.pyc matches C:\MYFILEDIRINFO\AppData\Local\Enthought\Cano
py\App\appdata\canopy-1.3.0.1715.win-x86_64\lib\_abcoll.py
import _abcoll # precompiled from C:\MYFILEDIRINFO\AppData\Local\Enthought\Canop
y\App\appdata\canopy-1.3.0.1715.win-x86_64\lib\_abcoll.pyc
# C:\MYFILEDIRINFO\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.3.0.1715.
win-x86_64\lib\abc.pyc matches C:\MYFILEDIRINFO\AppData\Local\Enthought\Canopy\A
pp\appdata\canopy-1.3.0.1715.win-x86_64\lib\abc.py
import abc # precompiled from C:\MYFILEDIRINFO\AppData\Local\Enthought\Canopy\Ap
p\appdata\canopy-1.3.0.1715.win-x86_64\lib\abc.pyc
# C:\MYFILEDIRINFO\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.3.0.1715.
win-x86_64\lib\_weakrefset.pyc matches C:\MYFILEDIRINFO\AppData\Local\Enthought\
Canopy\App\appdata\canopy-1.3.0.1715.win-x86_64\lib\_weakrefset.py
import _weakrefset # precompiled from C:\MYFILEDIRINFO\AppData\Local\Enthought\C
anopy\App\appdata\canopy-1.3.0.1715.win-x86_64\lib\_weakrefset.pyc
import _weakref # builtin
# C:\MYFILEDIRINFO\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.3.0.1715.
win-x86_64\lib\copy_reg.pyc matches C:\MYFILEDIRINFO\AppData\Local\Enthought\Can
opy\App\appdata\canopy-1.3.0.1715.win-x86_64\lib\copy_reg.py
import copy_reg # precompiled from C:\MYFILEDIRINFO\AppData\Local\Enthought\Cano
py\App\appdata\canopy-1.3.0.1715.win-x86_64\lib\copy_reg.pyc
# C:\MYFILEDIRINFO\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.3.0.1715.
win-x86_64\lib\re.pyc matches C:\MYFILEDIRINFO\AppData\Local\Enthought\Canopy\Ap
p\appdata\canopy-1.3.0.1715.win-x86_64\lib\re.py
import re # precompiled from C:\MYFILEDIRINFO\AppData\Local\Enthought\Canopy\App
\appdata\canopy-1.3.0.1715.win-x86_64\lib\re.pyc
# C:\MYFILEDIRINFO\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.3.0.1715.
win-x86_64\lib\sre_compile.pyc matches C:\MYFILEDIRINFO\AppData\Local\Enthought\
Canopy\App\appdata\canopy-1.3.0.1715.win-x86_64\lib\sre_compile.py
import sre_compile # precompiled from C:\MYFILEDIRINFO\AppData\Local\Enthought\C
anopy\App\appdata\canopy-1.3.0.1715.win-x86_64\lib\sre_compile.pyc
import _sre # builtin
# C:\MYFILEDIRINFO\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.3.0.1715.
win-x86_64\lib\sre_parse.pyc matches C:\MYFILEDIRINFO\AppData\Local\Enthought\Ca
nopy\App\appdata\canopy-1.3.0.1715.win-x86_64\lib\sre_parse.py
import sre_parse # precompiled from C:\MYFILEDIRINFO\AppData\Local\Enthought\Can
opy\App\appdata\canopy-1.3.0.1715.win-x86_64\lib\sre_parse.pyc
# C:\MYFILEDIRINFO\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.3.0.1715.
win-x86_64\lib\sre_constants.pyc matches C:\MYFILEDIRINFO\AppData\Local\Enthough
t\Canopy\App\appdata\canopy-1.3.0.1715.win-x86_64\lib\sre_constants.py
import sre_constants # precompiled from C:\MYFILEDIRINFO\AppData\Local\Enthought
\Canopy\App\appdata\canopy-1.3.0.1715.win-x86_64\lib\sre_constants.pyc
# C:\MYFILEDIRINFO\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.3.0.1715.
win-x86_64\lib\traceback.pyc matches C:\MYFILEDIRINFO\AppData\Local\Enthought\Ca
nopy\App\appdata\canopy-1.3.0.1715.win-x86_64\lib\traceback.py
import traceback # precompiled from C:\MYFILEDIRINFO\AppData\Local\Enthought\Can
opy\App\appdata\canopy-1.3.0.1715.win-x86_64\lib\traceback.pyc
# C:\MYFILEDIRINFO\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.3.0.1715.
win-x86_64\lib\sysconfig.pyc matches C:\MYFILEDIRINFO\AppData\Local\Enthought\Ca
nopy\App\appdata\canopy-1.3.0.1715.win-x86_64\lib\sysconfig.py
import sysconfig # precompiled from C:\MYFILEDIRINFO\AppData\Local\Enthought\Can
opy\App\appdata\canopy-1.3.0.1715.win-x86_64\lib\sysconfig.pyc
# C:\MYFILEDIRINFO\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.3.0.1715.
win-x86_64\lib\locale.pyc matches C:\MYFILEDIRINFO\AppData\Local\Enthought\Canop
y\App\appdata\canopy-1.3.0.1715.win-x86_64\lib\locale.py
import locale # precompiled from C:\MYFILEDIRINFO\AppData\Local\Enthought\Canopy
\App\appdata\canopy-1.3.0.1715.win-x86_64\lib\locale.pyc
import encodings # directory C:\MYFILEDIRINFO\AppData\Local\Enthought\Canopy\App
\appdata\canopy-1.3.0.1715.win-x86_64\lib\encodings
# C:\MYFILEDIRINFO\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.3.0.1715.
win-x86_64\lib\encodings\__init__.pyc matches C:\MYFILEDIRINFO\AppData\Local\Ent
hought\Canopy\App\appdata\canopy-1.3.0.1715.win-x86_64\lib\encodings\__init__.py

import encodings # precompiled from C:\MYFILEDIRINFO\AppData\Local\Enthought\Can
opy\App\appdata\canopy-1.3.0.1715.win-x86_64\lib\encodings\__init__.pyc
# C:\MYFILEDIRINFO\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.3.0.1715.
win-x86_64\lib\codecs.pyc matches C:\MYFILEDIRINFO\AppData\Local\Enthought\Canop
y\App\appdata\canopy-1.3.0.1715.win-x86_64\lib\codecs.py
import codecs # precompiled from C:\MYFILEDIRINFO\AppData\Local\Enthought\Canopy
\App\appdata\canopy-1.3.0.1715.win-x86_64\lib\codecs.pyc
import _codecs # builtin
# C:\MYFILEDIRINFO\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.3.0.1715.
win-x86_64\lib\encodings\aliases.pyc matches C:\MYFILEDIRINFO\AppData\Local\Enth
ought\Canopy\App\appdata\canopy-1.3.0.1715.win-x86_64\lib\encodings\aliases.py
import encodings.aliases # precompiled from C:\MYFILEDIRINFO\AppData\Local\Entho
ught\Canopy\App\appdata\canopy-1.3.0.1715.win-x86_64\lib\encodings\aliases.pyc
import operator # builtin
# C:\MYFILEDIRINFO\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.3.0.1715.
win-x86_64\lib\functools.pyc matches C:\MYFILEDIRINFO\AppData\Local\Enthought\Ca
nopy\App\appdata\canopy-1.3.0.1715.win-x86_64\lib\functools.py
import functools # precompiled from C:\MYFILEDIRINFO\AppData\Local\Enthought\Can
opy\App\appdata\canopy-1.3.0.1715.win-x86_64\lib\functools.pyc
import _functools # builtin
import _locale # builtin
# C:\MYFILEDIRINFO\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.3.0.1715.
win-x86_64\lib\encodings\cp1252.pyc matches C:\MYFILEDIRINFO\AppData\Local\Entho
ught\Canopy\App\appdata\canopy-1.3.0.1715.win-x86_64\lib\encodings\cp1252.py
import encodings.cp1252 # precompiled from C:\MYFILEDIRINFO\AppData\Local\Enthou
ght\Canopy\App\appdata\canopy-1.3.0.1715.win-x86_64\lib\encodings\cp1252.pyc
import custom_tools # directory C:\MYFILEDIRINFO\AppData\Local\Enthought\Canopy\
App\appdata\canopy-1.3.0.1715.win-x86_64\lib\custom_tools
# C:\MYFILEDIRINFO\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.3.0.1715.
win-x86_64\lib\custom_tools\__init__.pyc matches C:\MYFILEDIRINFO\AppData\Local\
Enthought\Canopy\App\appdata\canopy-1.3.0.1715.win-x86_64\lib\custom_tools\__ini
t__.py
import custom_tools # precompiled from C:\MYFILEDIRINFO\AppData\Local\Enthought\
Canopy\App\appdata\canopy-1.3.0.1715.win-x86_64\lib\custom_tools\__init__.pyc
Enthought Canopy Python 2.7.6 | 64-bit | (default, Jan 29 2014, 17:03:59) [MSC v
.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
# C:\MYFILEDIRINFO\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.3.0.1715.
win-x86_64\lib\__future__.pyc matches C:\MYFILEDIRINFO\AppData\Local\Enthought\C
anopy\App\appdata\canopy-1.3.0.1715.win-x86_64\lib\__future__.py
import __future__ # precompiled from C:\MYFILEDIRINFO\AppData\Local\Enthought\Ca
nopy\App\appdata\canopy-1.3.0.1715.win-x86_64\lib\__future__.pyc
# C:\MYFILEDIRINFO\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.3.0.1715.
win-x86_64\lib\subprocess.pyc matches C:\MYFILEDIRINFO\AppData\Local\Enthought\C
anopy\App\appdata\canopy-1.3.0.1715.win-x86_64\lib\subprocess.py
import subprocess # precompiled from C:\MYFILEDIRINFO\AppData\Local\Enthought\Ca
nopy\App\appdata\canopy-1.3.0.1715.win-x86_64\lib\subprocess.pyc
import gc # builtin
import time # builtin
# C:\MYFILEDIRINFO\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.3.0.1715.
win-x86_64\lib\threading.pyc matches C:\MYFILEDIRINFO\AppData\Local\Enthought\Ca
nopy\App\appdata\canopy-1.3.0.1715.win-x86_64\lib\threading.py
import threading # precompiled from C:\MYFILEDIRINFO\AppData\Local\Enthought\Can
opy\App\appdata\canopy-1.3.0.1715.win-x86_64\lib\threading.pyc
import thread # builtin
# C:\MYFILEDIRINFO\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.3.0.1715.
win-x86_64\lib\collections.pyc matches C:\MYFILEDIRINFO\AppData\Local\Enthought\
Canopy\App\appdata\canopy-1.3.0.1715.win-x86_64\lib\collections.py
import collections # precompiled from C:\MYFILEDIRINFO\AppData\Local\Enthought\C
anopy\App\appdata\canopy-1.3.0.1715.win-x86_64\lib\collections.pyc
import _collections # builtin
# C:\MYFILEDIRINFO\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.3.0.1715.
win-x86_64\lib\keyword.pyc matches C:\MYFILEDIRINFO\AppData\Local\Enthought\Cano
py\App\appdata\canopy-1.3.0.1715.win-x86_64\lib\keyword.py
import keyword # precompiled from C:\MYFILEDIRINFO\AppData\Local\Enthought\Canop
y\App\appdata\canopy-1.3.0.1715.win-x86_64\lib\keyword.pyc
# C:\MYFILEDIRINFO\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.3.0.1715.
win-x86_64\lib\heapq.pyc matches C:\MYFILEDIRINFO\AppData\Local\Enthought\Canopy
\App\appdata\canopy-1.3.0.1715.win-x86_64\lib\heapq.py
import heapq # precompiled from C:\MYFILEDIRINFO\AppData\Local\Enthought\Canopy\
App\appdata\canopy-1.3.0.1715.win-x86_64\lib\heapq.pyc
import itertools # builtin
import _heapq # builtin
import msvcrt # builtin
import _subprocess # builtin
# ./lib\getpath.pyc matches ./lib\getpath.py
import getpath # precompiled from ./lib\getpath.pyc
import _winreg # builtin
# cleanup __main__
# cleanup[1] __future__
# cleanup[1] _collections
# cleanup[1] locale
# cleanup[1] functools
# cleanup[1] encodings
# cleanup[1] site
# cleanup[1] subprocess
# cleanup[1] sysconfig
# cleanup[1] operator
# cleanup[1] custom_tools
# cleanup[1] msvcrt
# cleanup[1] gc
# cleanup[1] _heapq
# cleanup[1] _subprocess
# cleanup[1] abc
# cleanup[1] _weakrefset
# cleanup[1] sre_constants
# cleanup[1] re
# cleanup[1] collections
# cleanup[1] _codecs
# cleanup[1] nt
# cleanup[1] _warnings
# cleanup[1] zipimport
# cleanup[1] getpath
# cleanup[1] encodings.cp1252
# cleanup[1] _winreg
# cleanup[1] codecs
# cleanup[1] _functools
# cleanup[1] _locale
# cleanup[1] keyword
# cleanup[1] thread
# cleanup[1] signal
# cleanup[1] traceback
# cleanup[1] itertools
# cleanup[1] encodings.aliases
# cleanup[1] exceptions
# cleanup[1] _weakref
# cleanup[1] heapq
# cleanup[1] sre_compile
# cleanup[1] threading
# cleanup[1] _sre
# cleanup[1] sre_parse
# cleanup[2] copy_reg
# cleanup[2] types
# cleanup[2] errno
# cleanup[2] _abcoll
# cleanup[2] ntpath
# cleanup[2] genericpath
# cleanup[2] stat
# cleanup[2] warnings
# cleanup[2] UserDict
# cleanup[2] os.path
# cleanup[2] linecache
# cleanup[2] time
# cleanup[2] os
# cleanup sys
# cleanup __builtin__
# cleanup ints: 20 unfreed ints
# cleanup floats: 2 unfreed floats
7yl4r
 
Posts: 15
Joined: Fri Apr 18, 2014 3:44 pm

Re: "from core import G"?

Postby duststorm » Thu Apr 24, 2014 12:01 am

Code: Select all
from core import G

works. As long as you have your python paths set up properly (makehuman.py does that).
MakeHuman™ developer
User avatar
duststorm
 
Posts: 2563
Joined: Fri Jan 27, 2012 11:57 am
Location: Belgium

Re: "from core import G"?

Postby 7yl4r » Thu May 01, 2014 10:54 pm

duststorm wrote:
Code: Select all
from core import G

works. As long as you have your python paths set up properly (makehuman.py does that).


I see my mistake now. I didn't account for the path changes properly and had a bad OpenGL install.
7yl4r
 
Posts: 15
Joined: Fri Apr 18, 2014 3:44 pm

Re: "from core import G"?

Postby aliiab » Wed Feb 21, 2018 8:02 pm

I think, my question is adjacent to this one. Where is module "core" located? is it basic python module or special makehuman module? It's used in a lot of plugins for makehuman (not only mhapi). I want to look through the code of this module.
aliiab
 
Posts: 1
Joined: Wed Feb 21, 2018 7:39 pm

Re: "from core import G"?

Postby loki1950 » Wed Feb 21, 2018 9:15 pm

The path to core on my source version of makehuman on Linux is /home/denis/Progects/Hg/makehuman-stable/makehuman/lib the Hg folder is where I put all Mercurial based projects.

Enjoy the Choice :)
my box::HP Envy i5-6400 @2Q70GHzx4 8 Gb ram/1 Tb(Win10 64)/3 Tb Mint 19.2/GTX745 4Gb acer S243HL K222HQL
Q8200/Asus P5QDLX/8 Gb ram/WD 2Tb 2-500 G HD/GF GT640 2Gb Mint 17.3 64 bit Win 10 32 bit acer and Lenovo Ideapad 320-15ABR Win 10/Mint 19
User avatar
loki1950
 
Posts: 925
Joined: Thu Dec 18, 2014 6:27 pm
Location: Ottawa,Ontario

Re: "from core import G"?

Postby joepal » Thu Feb 22, 2018 1:09 pm

Core is here:

https://github.com/makehumancommunity/m ... ib/core.py

As you can see "G" is a variable which is an instance of Globals.

Note that "G" gets further populated during the start-up sequence. Especially G.app is important. It is an instance of MHApplication, which is defined at line 152 here:

https://github.com/makehumancommunity/m ... /mhmain.py

Confusingly enough there is also a directory called "core", but it does not formally wrap a python module, i.e there is not __init__.py.
Joel Palmius (LinkedIn)
MakeHuman Infrastructure Manager
http://www.palmius.com/joel
joepal
 
Posts: 3528
Joined: Wed Jun 04, 2008 11:20 am


Return to Python scripts

Who is online

Users browsing this forum: No registered users and 0 guests