Using the data_files mechanism, I have not found a way to reliably find out where exactly the package is going to be installed. For python < 3.8 adding to sys.path or os.environ does not solve anything. The folder can be added with os.add_dlls_directory, but that does not work for python < 3.8, which is a problem right now. Putting them into a subfolder into the package folder pyreadr does not work as the dlls are copied but they are not found at import time. However, doing this breaks compilation on Mac for some reason. If I put the dlls directly on the package folder (pyreadr) and say setup.py to treat them as package data, then on windows it works like a charm, you can import without having to do anything else as the dlls are effectively copied to the package directory. No idea how to do that at the moment, but suggestions are welcome. The definitive solution would be to able to copy the dlls (data) to wherever the code goes and not somewhere else, automatically, without having to guess where the system is going to install them. The solutions are either copying the dlls where the code is (then nothing else is needed), or to do os.add_dll_directory to the the directory where the dlls are. Now, when installing from windows app store, what I get is that the package is installed into a weird place LocalCache\local-packages\Python39\site-packages\pyreadr while the dlls are installed into a different place LocalCache\local-packages\Lib\site-packages\pyreadr, that is, the dlls are not togheter with the python code anymore. Then my installer copies into this folder the python code and the dlls. For instance, if you install with miniconda, you get it in Miniconda3\Lib\site-packages\pyreadr. The problem is that depending how you install Python, the folder structure of where the packages get installed looks different. Platform (windows, macOS, linux, 32 or 64 bit)Įxperience Windows Feature Experience Pack 120.2212.3740.0.How did you install pyreadr? (pip, conda, directly from repo).(Optional, doesn't really make a difference) Set PYTHONPATH $Env:PYTHONPATH = $Env:PATH to match PATH, which points to the folders with the DLLs.Install pandas and pyreadr with pip ( python -m pip install pandas pyreadr).librdata import Parser ImportError: DLL load failed while importing librdata: No se puede encontrar el mó dulo especificado. _pyreadr_parser import PyreadrParser, ListObjectsParser File "C:\Users\Eugenio\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pyreadr\_pyreadr_parser.py", line 17, in from. pyreadr import read_r, list_objects, write_rds, write_rdata, download_file File "C:\Users\Eugenio\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pyreadr\pyreadr.py", line 10, in from. When you hit F8 resources is already present and to update it you need to use importlib's reload function.Import pyreadr Traceback ( most recent call last):įile "", line 1, in File "C:\Users\Eugenio\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pyreadr\_init_.py", line 1, in from. The first time you enable the add-on, resources is hoisted into the globals for this module (your add-on). resources import (function1, function2, function3) What tends to work is this (or something similar): if 'resources' in globals():įrom. Most add-ons have some form of explicit reload of their modules. You can control what your add-on does during the reload event (triggered by F8). This will work once, but when you go to reload python F8 - as you will most likely do a lot during development - the changes you make to the functions (function1, function2, function3) will not be pulled in - globals() will still contain the cached versions of the old functions. SomeAddonĪnd you want to import a few functions from resources.py into _init_.py, then you do from. If you have a folder called 'SomeAddon' and it contains the following files. This reimport / and local imports topic is not necessarily obvious in a Blender add-on context. Just like topology isn't strictly a Blender specific topic yet we still cover it sometimes. Mostly this is a Python question, but it can be helpful to see working examples.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |