-
-
Notifications
You must be signed in to change notification settings - Fork 318
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pandas with Python 3.12 #470
Comments
This looks more like a problem with your python installation. Can you
confirm that your script works from a python console? Also make
sure python4delphi is pointing to the right python dlls, ie name and path.
…On Fri, Apr 12, 2024 at 9:56 AM comdora ***@***.***> wrote:
Hi, using your demo1, I have tried to compile next python scrip
import numpy as np
import pandas as pd
rg = np.random.default_rng()
def generate_data(n_features, n_values):
features = rg.random((n_features, n_values))
weights = rg.random((1, n_values))[0]
targets = np.random.choice([0,1], n_features)
data = pd.DataFrame(features, columns=["x0", "x1", "x2"])
data["targets"] = targets
return data, weights
data, weights = generate_data(4,3)
print(data)
I have received next messages:
Traceback (most recent call last):
File "", line 2, in
File
"C:\Users\ivan\AppData\Local\Programs\Python\Python312\Lib\site-packages\pandas_
*init*_.py", line 62, in
from pandas.core.api import (
File
"C:\Users\ivan\AppData\Local\Programs\Python\Python312\Lib\site-packages\pandas\core\api.py",
line 47, in
from pandas.core.groupby import (
File
"C:\Users\ivan\AppData\Local\Programs\Python\Python312\Lib\site-packages\pandas\core\groupby_
*init*_.py", line 1, in
from pandas.core.groupby.generic import (
File
"C:\Users\ivan\AppData\Local\Programs\Python\Python312\Lib\site-packages\pandas\core\groupby\generic.py",
line 68, in
from pandas.core.frame import DataFrame
File
"C:\Users\ivan\AppData\Local\Programs\Python\Python312\Lib\site-packages\pandas\core\frame.py",
line 149, in
from pandas.core.generic import (
File
"C:\Users\ivan\AppData\Local\Programs\Python\Python312\Lib\site-packages\pandas\core\generic.py",
line 193, in
from pandas.core.window import (
File
"C:\Users\ivan\AppData\Local\Programs\Python\Python312\Lib\site-packages\pandas\core\window_
*init*_.py", line 1, in
from pandas.core.window.ewm import (
File
"C:\Users\ivan\AppData\Local\Programs\Python\Python312\Lib\site-packages\pandas\core\window\ewm.py",
line 11, in
import pandas._libs.window.aggregations as window_aggregations
ImportError: DLL load failed while importing aggregations: The specified
module could not be found.
But, same script is executed from command prompt and result is shown on
the attached image. (I am in process of learning Python4Delphi)
Screenshot.2024-04-12.at.18.54.42.png (view on web)
<https://urldefense.com/v3/__https://github.com/pyscripter/python4delphi/assets/6955754/e850931e-6e34-4a5b-ae13-0e6310d46ee4__;!!K-Hz7m0Vt54!kfnlxrFqwrKOf9mSq3HArTx9CuC8bUq1ScVyy8_-_jIyEuS8LVbK62Lk3qJUmTqzKMRtVFTBm3SPqENpxKImE58_BsGFCQ$>
Thanks in advance
Bojan
—
Reply to this email directly, view it on GitHub
<https://urldefense.com/v3/__https://github.com/pyscripter/python4delphi/issues/470__;!!K-Hz7m0Vt54!kfnlxrFqwrKOf9mSq3HArTx9CuC8bUq1ScVyy8_-_jIyEuS8LVbK62Lk3qJUmTqzKMRtVFTBm3SPqENpxKImE59Tk1Dw1Q$>,
or unsubscribe
<https://urldefense.com/v3/__https://github.com/notifications/unsubscribe-auth/AAIBSDWTZCAJXK7UTXIH6L3Y5AG35AVCNFSM6AAAAABGEO4UEGVHI2DSMVQWIX3LMV43ASLTON2WKOZSGI2DANJTG4YTMOA__;!!K-Hz7m0Vt54!kfnlxrFqwrKOf9mSq3HArTx9CuC8bUq1ScVyy8_-_jIyEuS8LVbK62Lk3qJUmTqzKMRtVFTBm3SPqENpxKImE59J38EFYw$>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
--
Herbert Sauro, Professor
Director: NIH Center for model reproducibility
University of Washington, Bioengineering
206-685-2119, www.sys-bio.org, http://reproduciblebiomodels.org/
Mobile: 206-880-8093
***@***.***
Books: http://books.analogmachine.org/
|
Thanks for your answer. I have only one python version installed on the computer, and dll's can't be messed. Also, as you can see on the image, script works when it is executed "directly". |
I just tried it on a delphi app I have that lets me run python and your
code worked fine, see output below. I am using python3.11 however
x0 x1 x2 targets
0 0.743486 0.664062 0.596558 1
1 0.797436 0.187368 0.624118 0
2 0.678791 0.711799 0.145333 0
3 0.570934 0.093008 0.521779 0
I am also using an embedded python and using the following lines to set up
the pythonengine:
PythonEngine.DllPath := ExtractFileDir(ParamStr(0)) + '\\Python';
PythonEngine.DllName := 'python311.dll';
…On Fri, Apr 12, 2024 at 10:55 AM comdora ***@***.***> wrote:
Thanks for your answer. I have only one python version installed on the
computer, and dll's can't be messed. Also, as you can see on the image,
script works when it is executed "directly".
—
Reply to this email directly, view it on GitHub
<https://urldefense.com/v3/__https://github.com/pyscripter/python4delphi/issues/470*issuecomment-2052217514__;Iw!!K-Hz7m0Vt54!lDf-6yN_nohY4uCEZTdpbWXzTahuaoDWV3b8Au6UQSBAaAuHoHaFeJofvhVMN8Q2qqhrQg9VGJXY7SB6aDiSx0LEdjVq8A$>,
or unsubscribe
<https://urldefense.com/v3/__https://github.com/notifications/unsubscribe-auth/AAIBSDWIBG4VREL4CN37JM3Y5ANYLAVCNFSM6AAAAABGEO4UEGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANJSGIYTONJRGQ__;!!K-Hz7m0Vt54!lDf-6yN_nohY4uCEZTdpbWXzTahuaoDWV3b8Au6UQSBAaAuHoHaFeJofvhVMN8Q2qqhrQg9VGJXY7SB6aDiSx0KrxF0i_A$>
.
You are receiving this because you commented.Message ID:
***@***.***>
--
Herbert Sauro, Professor
Director: NIH Center for model reproducibility
University of Washington, Bioengineering
206-685-2119, www.sys-bio.org, http://reproduciblebiomodels.org/
Mobile: 206-880-8093
***@***.***
Books: http://books.analogmachine.org/
|
I have tested on other computer, Delphi 12.0, Python 3.11, script is executed OK. |
Result := PyEval_EvalCode(Code, _globals, _locals ); line 5153 in PythonEngine, Result is nil |
I'm still using Delphi 11 patch, so can't advise on D12.
…On Fri, Apr 12, 2024 at 2:00 PM comdora ***@***.***> wrote:
I have tested on other computer, Delphi 12.0, Python 3.11, script is
executed OK.
On the computer with Delphi 12.1, Python 3.12 error still exists. Script
execution from command prompt, on the both computers is executed OK.
—
Reply to this email directly, view it on GitHub
<https://urldefense.com/v3/__https://github.com/pyscripter/python4delphi/issues/470*issuecomment-2052523897__;Iw!!K-Hz7m0Vt54!h2lcv8mqJT-UKkeTc-NX0S3vs-Khx1uB_mY0oC5J2AaNWztTFYs_IqFsf6kSeZhuLWxf8fPozOPRz0lW-HLctCnbX88jbw$>,
or unsubscribe
<https://urldefense.com/v3/__https://github.com/notifications/unsubscribe-auth/AAIBSDVYYKXQTVWFLJ37RMTY5BDO5AVCNFSM6AAAAABGEO4UEGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANJSGUZDGOBZG4__;!!K-Hz7m0Vt54!h2lcv8mqJT-UKkeTc-NX0S3vs-Khx1uB_mY0oC5J2AaNWztTFYs_IqFsf6kSeZhuLWxf8fPozOPRz0lW-HLctCkLTxnA4w$>
.
You are receiving this because you commented.Message ID:
***@***.***>
--
Herbert Sauro, Professor
Director: NIH Center for model reproducibility
University of Washington, Bioengineering
206-685-2119, www.sys-bio.org, http://reproduciblebiomodels.org/
Mobile: 206-880-8093
***@***.***
Books: http://books.analogmachine.org/
|
@comdora As I said above, it appears to be a python/pandas installation issue. It is not related to the Delphi version, since we are using the same version. If you google for "ImportError: DLL load failed while importing aggregations: The specified module could not be found" you will see it has happened to others and typically gets resolved by uninstalling/reinstalling pandas and possibly python. |
I have installed python 3.12.3 to make sure we are using the same python version and it still works fine here. We are using the same Delphi, python and P4D versions and here it works and at your side it doesn't. I have no idea why. And if I cannot reproduce the error, I cannot fix it. Can you try one last thing? Try running: import sys
print(sys.path) What do you get? |
Cannot reproduce and no feedback. |
Hi, using your demo1, I have tried to compile next python scrip
import numpy as np
import pandas as pd
rg = np.random.default_rng()
def generate_data(n_features, n_values):
features = rg.random((n_features, n_values))
weights = rg.random((1, n_values))[0]
targets = np.random.choice([0,1], n_features)
data = pd.DataFrame(features, columns=["x0", "x1", "x2"])
data["targets"] = targets
return data, weights
data, weights = generate_data(4,3)
print(data)
I have received next messages:
Traceback (most recent call last):
File "", line 2, in
File "C:\Users\ivan\AppData\Local\Programs\Python\Python312\Lib\site-packages\pandas_init_.py", line 62, in
from pandas.core.api import (
File "C:\Users\ivan\AppData\Local\Programs\Python\Python312\Lib\site-packages\pandas\core\api.py", line 47, in
from pandas.core.groupby import (
File "C:\Users\ivan\AppData\Local\Programs\Python\Python312\Lib\site-packages\pandas\core\groupby_init_.py", line 1, in
from pandas.core.groupby.generic import (
File "C:\Users\ivan\AppData\Local\Programs\Python\Python312\Lib\site-packages\pandas\core\groupby\generic.py", line 68, in
from pandas.core.frame import DataFrame
File "C:\Users\ivan\AppData\Local\Programs\Python\Python312\Lib\site-packages\pandas\core\frame.py", line 149, in
from pandas.core.generic import (
File "C:\Users\ivan\AppData\Local\Programs\Python\Python312\Lib\site-packages\pandas\core\generic.py", line 193, in
from pandas.core.window import (
File "C:\Users\ivan\AppData\Local\Programs\Python\Python312\Lib\site-packages\pandas\core\window_init_.py", line 1, in
from pandas.core.window.ewm import (
File "C:\Users\ivan\AppData\Local\Programs\Python\Python312\Lib\site-packages\pandas\core\window\ewm.py", line 11, in
import pandas._libs.window.aggregations as window_aggregations
ImportError: DLL load failed while importing aggregations: The specified module could not be found.
But, same script is executed from command prompt and result is shown on the attached image. (I am in process of learning Python4Delphi)

Thanks in advance
Bojan
The text was updated successfully, but these errors were encountered: