pycall.rb icon indicating copy to clipboard operation
pycall.rb copied to clipboard

uninitialized constant PyCall::LibPython::Helpers

Open MuthukkaruppanSubramanian opened this issue 3 years ago • 7 comments

irb(main):001:0> require 'pycall/import'
=> true
irb(main):002:0> include PyCall::Import
=> Object
irb(main):003:0> pyimport :os
DEBUG(find_libpython) find_libpython("C:\\Users\\60026865.ICU_DOMAIN\\AppData\\Local\\Programs\\Python\\Python38-32\\Lib")
DEBUG(find_libpython) investigate_python_config("C:\\Users\\60026865.ICU_DOMAIN\\AppData\\Local\\Programs\\Python\\Python38-32\\Lib")
Traceback (most recent call last):
        8: from C:/Ruby25-x64/bin/irb.cmd:19:in `<main>'
        7: from (irb):3
        6: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/pycall-1.4.0/lib/pycall/import.rb:18:in `pyimport'
        5: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/pycall-1.4.0/lib/pycall.rb:73:in `import_module'
        4: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/pycall-1.4.0/lib/pycall/init.rb:16:in `const_missing'
        3: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/pycall-1.4.0/lib/pycall/init.rb:33:in `init'
        2: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/pycall-1.4.0/lib/pycall/libpython/finder.rb:42:in `find_libpython'
        1: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/pycall-1.4.0/lib/pycall/libpython/finder.rb:37:in `find_python_config'
PyCall::PythonNotFound (PyCall::PythonNotFound)
irb(main):004:0> pyimport :os
Traceback (most recent call last):
        4: from C:/Ruby25-x64/bin/irb.cmd:19:in `<main>'
        3: from (irb):4
        2: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/pycall-1.4.0/lib/pycall/import.rb:18:in `pyimport'
        1: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/pycall-1.4.0/lib/pycall.rb:73:in `import_module'
NameError (uninitialized constant PyCall::LibPython::Helpers)

Environment Variables:

C:\WINDOWS\system32>echo %PYTHON%
C:\Users\60026865.ICU_DOMAIN\AppData\Local\Programs\Python\Python38-32\Lib

C:\WINDOWS\system32>echo %PYTHON_CONFIGURE_OPTS%
'--enable-shared'

Also added python location to environment variables.

You need to specify the path of python executable in PYTHON environment variable.

mrkn avatar Jun 29 '21 12:06 mrkn

Hi,

Thanks for response. I had added the following value to PYTHON env var.

"C:\Users\_user_name\AppData\Local\Programs\Python\Python38-32\pythonw.exe"

but still I could see issues as below

irb(main):002:0> require 'pycall/import'
=> true
irb(main):003:0> include PyCall::Import
=> Object
irb(main):004:0> pyimport :os
DEBUG(find_libpython) find_libpython("C:\\Users\\_user_name\\AppData\\Local\\Programs\\Python\\Python38-32\\Lib")
DEBUG(find_libpython) investigate_python_config("C:\\Users\\_user_name\\AppData\\Local\\Programs\\Python\\Python38-32\\Lib")
Traceback (most recent call last):
        8: from C:/Ruby25-x64/bin/irb.cmd:19:in `<main>'
        7: from (irb):4
        6: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/pycall-1.4.0/lib/pycall/import.rb:18:in `pyimport'
        5: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/pycall-1.4.0/lib/pycall.rb:73:in `import_module'
        4: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/pycall-1.4.0/lib/pycall/init.rb:16:in `const_missing'
        3: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/pycall-1.4.0/lib/pycall/init.rb:33:in `init'
        2: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/pycall-1.4.0/lib/pycall/libpython/finder.rb:42:in `find_libpython'
        1: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/pycall-1.4.0/lib/pycall/libpython/finder.rb:37:in `find_python_config'
PyCall::PythonNotFound (PyCall::PythonNotFound)
irb(main):005:0> pyimport :os
Traceback (most recent call last):
        4: from C:/Ruby25-x64/bin/irb.cmd:19:in `<main>'
        3: from (irb):5
        2: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/pycall-1.4.0/lib/pycall/import.rb:18:in `pyimport'
        1: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/pycall-1.4.0/lib/pycall.rb:73:in `import_module'
NameError (uninitialized constant PyCall::LibPython::Helpers)
irb(main):006:0>

Really appreciate your response. Thanks

I seem to be having the same problem after installing aeneas with their all-in-one package. I suspect, at least in my case, that I have the opposite problem, that I have too many versions of python installed and pycall is confused.

image

Zaxser avatar Jul 28 '21 23:07 Zaxser

Hm. Alright. Tried a few things, none of them worked. Dug around in pycall's code a bit. It looks like it's asking for ENV["PYTHON"] but not finding it. Actually, I had no idea that this is variable was here.

Anyway, after I added a PYTHON path to the variable list (make sure it's not SYSTEM variables, at the bottom of the environmental variable screen, but the ENVIRONMENTAL variables at the top), my scripts that used Pycall started working again. Thank you.

Zaxser avatar Jul 29 '21 01:07 Zaxser

Hmm. It seems to work with one python module (genanki) and not another (aeneas), I'm getting another const missing error, The solution is probably to add more variables.

        5: from aeneas-timings.rb:3:in `<main>'
        4: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/pycall-1.4.1/lib/pycall.rb:74:in `import_module'
        3: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/pycall-1.4.1/lib/pycall/init.rb:16:in `const_missing'
        2: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/pycall-1.4.1/lib/pycall/init.rb:33:in `init'
        1: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/pycall-1.4.1/lib/pycall/libpython/finder.rb:42:in `find_libpython'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/pycall-1.4.1/lib/pycall/libpython/finder.rb:37:in `find_python_config': PyCall::PythonNotFound (PyCall::PythonNotFound)

Zaxser avatar Jul 29 '21 01:07 Zaxser

Oh god. It's looking for a variable called PYTHONHOME in my environmental variables. It's not there, and then... it looks like it's deciding to use_conda, except I don't have anaconda. Hmm.

In my head:

"He swallowed the Anaconda to shave the Yak; He swallowed the Yak to catch the Python; To run on Ruby; To catch the fly; I don't know why he swallowed the fly..."

Zaxser avatar Jul 29 '21 01:07 Zaxser

Eventually, I just gave up and set up an environment on WSL, like I probably should have done in the first place.

Zaxser avatar Jul 30 '21 22:07 Zaxser