yglukhov / nimpy

Nim - Python bridge

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Could not find platform dependent libraries <exec_prefix>

inverimus opened this issue · comments

I get this line "Could not find platform dependent libraries <exec_prefix>" when using python 3.11 with nimpy on windows. Using python in any other way does not cause this message to appear. It doesn't seem to cause any problems and everything works normally, just wondering if anyone knows of a way to fix this. It doesn't happen with any previous version of python I've tried.

commented

I too am having this problem. (Python 3.9.13 Anaconda install on Windows).

It seems it has more to do with anaconda/venv rather than with nimpy: https://stackoverflow.com/questions/19292957/how-can-i-troubleshoot-python-could-not-find-platform-independent-libraries-pr

I've never used venv so can't tell for sure. I'm open to suggestions if there's anything we can do.

I was struggling for a while trying to call a python func FROM nim, but the func depends on a library installed in a virtual env

from pyfiglet import Figlet

def test():
    f = Figlet(font='slant')
    print(f.renderText('text to render'))

here is my nim code and here is the compile script

nim c -r main.nim
import strutils
import nimpy

let py = pyImport("main")

discard py.test()

when compiling I would get an error saying the module was not found

Error: unhandled exception: <class 'ModuleNotFoundError'>: No module named 'pyfiglet' [Exception]

I solved this by modifying the sys path IN my python script to add the sitepackages of my venv

import sys
sys.path.append(r'C:\Users\...\Desktop\Scripts\Temp_Projects\nimpy_test_venv_interop_10_06_2023-01_25PM\venv\Lib\site-packages')

from pyfiglet import Figlet
f = Figlet(font='slant')

def test():
    print(f.renderText('text to render'))