ah, progress...

ant ant at anthive.com
Fri Dec 21 01:06:24 EST 2018


dieter wrote:
> ant <ant at anthive.com> writes:
>> ant wrote:
>> ...
>>> (env) me at ant(26)~/src/test$ ngfp
>>> Traceback (most recent call last):
>>>   File "/home/me/src/env/bin/ngfp", line 7, in <module>
>>>     from ngfp import main
>>> ImportError: cannot import name 'main' from 'ngfp' (/home/me/src/salsa/env/lib/python3.7/site-packages/ngfp/__init__.py)
>> ...
>> hmmm, but my main is defined in ngfp.py
>
> The error message tells you that it looks for "main"
> in "...ngfp/__init__.py", not in "ngfp.py".

  i took an examply python program called afew and
edited it down to work for a very simple program
which i then took my other code and put it in that
directory structure to make sure i wasn't doing
anything strange, but i still ended up where 
running the program one way works and running it
the other way it seems to miss something important
which i don't understand.

  in order to get this far below i had to edit each
file and put a try: except: around each import
statment checking if the module could be found
like (as an example):

try:
    import config as cfg
except:
    import frog.config as cfg


this is very frustrating because the following makes 
no sense to me:

when i run the code within the directory like this i get:
=====  this works as it should
(env) me at ant(30)~/src/salsa/frog/frog$ python3 ngfp.py 
current_dir :  /home/me/src/salsa/frog/frog
(env) me at ant(31)~/src/salsa/frog/frog$ 
=====

when i pack it up and then install it using (and then run it via 
the script):
===== it doesn't work, but the directory is the same...?????
(env) me at ant(150)~/src/salsa/test$ pip3 --no-cache-dir install -e ../frog/ --force-reinstall
Obtaining file:///home/me/src/salsa/frog
Requirement already satisfied: pyglet>=1.3.0 in /home/me/src/salsa/env/lib/python3.7/site-packages (from frog==1.0.0)
Requirement already satisfied: future in /home/me/src/salsa/env/lib/python3.7/site-packages (from pyglet>=1.3.0->frog==1.0.0)
Installing collected packages: frog
  Found existing installation: frog 1.0.0
    Uninstalling frog-1.0.0:
      Successfully uninstalled frog-1.0.0
  Running setup.py develop for frog
Successfully installed frog
(env) me at ant(151)~/src/salsa/test$ frog
current_dir :  /home/me/src/salsa/frog/frog
Traceback (most recent call last):
  File "/home/me/src/salsa/env/bin/frog", line 11, in <module>
    load_entry_point('frog', 'console_scripts', 'frog')()
  File "/home/me/src/salsa/frog/frog/commands.py", line 12, in main
    inner_main()
  File "/home/me/src/salsa/frog/frog/ngfp.py", line 284, in main
    window = Window(width=cfg.img_pix*(cfg.game_cols+cfg.control_cols+3), height=cfg.img_pix*(cfg.game_rows+2), caption="Ngfp", resizable=True, fullscreen=False, visible=False)
  File "/home/me/src/salsa/frog/frog/ngfp.py", line 63, in __init__
    MyInitStuff (self)
  File "/home/me/src/salsa/frog/frog/my_init.py", line 113, in MyInitStuff
    self.game_bg_image  = pyglet.image.load("png/mirrors/00_bg.png")
  File "/home/me/src/salsa/env/lib/python3.7/site-packages/pyglet/image/__init__.py", line 180, in load
    file = open(filename, 'rb')
FileNotFoundError: [Errno 2] No such file or directory: 'png/mirrors/00_bg.png'
(env) me at ant(152)~/src/salsa/test$ 
=====

  the paths are exactly the same when i print the current
directory.

  the png directory is there and the image is there.

  ugh, time to sleep...


  ant



More information about the Python-list mailing list