#๐Ÿ”’ I am so confused with python - rust programmer using python to work with a python package.

8 messages ยท Page 1 of 1 (latest)

prime plover
#

1 -> I have a folder with the path lca_llm\python_scripts. it is used for storing python scripts for generating moelcular properties from PADELPY.

2-> within here there are two files :

a test file: testpadel.py

from padelpy import from_smiles

Define the SMILES string

smiles = "CCCO"

Generate the descriptors for the given SMILES string

descriptors = from_smiles(smiles)

Print the first 5 descriptors

first_5_descriptors = {key: descriptors[key] for key in list(descriptors)[:5]}
print(first_5_descriptors)

3- > and an api call that posts a smiles to :

import sys
import json
from padelpy import from_smiles

def generate_padel_descriptors(smiles):
try:
# Generate PaDEL descriptors
descriptors = from_smiles(smiles)

    # Convert all values to float where possible, otherwise keep as string
    for key, value in descriptors.items():
        try:
            descriptors[key] = float(value)
        except ValueError:
            pass  # Keep as string if can't convert to float
    
    return json.dumps(descriptors)
except Exception as e:
    return json.dumps({"error": f"Failed to generate PaDEL descriptors: {str(e)}"})

if name == "main":
if len(sys.argv) != 2:
print(json.dumps({"error": "Please provide a SMILES string as an argument"}))
else:
print(generate_padel_descriptors(sys.argv[1]))

  • here is the problem, when i activate my environment and run each file they work. they generate the descriptors. the descriptor generation process requires the formation of a csv. When I run my web application using AXUM RUST, the csv can no longer be creasted which is used to generate the descriptors. Why does the Python script work when executed directly from the command line, but fails when called from the Rust application. The main issue seems to be related to file permissions or the working directory when the script is called from Rust.
flat axleBOT
#

@prime plover

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

hoary orbit
#

!codeblock

flat axleBOT
#
Formatting code on Discord

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

For long code samples, you can use our pastebin.

hoary orbit
#

Please put it in this format so it is easier to read your code

undone mountain
flat axleBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.