python code runs on other OS but not on MacOS

I have a Python code that parses XML string. When I run that code on MacOS, it shows me an error. But when I run the same code on my Linux machine or on Windows it works completely fine. I'm wondering how is possible for a platform-independent language that runs on Linux but not on Mac.

from lxml.etree import fromstring


s = """<Abstract><AbstractText>The genus Cinchona is known for a range of alkaloids, such as quinine, quinidine, cinchonine, and cinchonidine. Cinchona bark has been used as an antimalarial agent for more than 400 years. Quinine was first isolated in 1820 and is still acknowledged in the therapy of chloroquine-resistant falciparum malaria; in lower dosage quinine has been used as treatment for leg cramps since the 1940s. Here we report the effects of the quinoline derivatives quinine, quinidine, and chloroquine on human adult and fetal muscle nicotinic acetylcholine receptors (nAChRs). It could be demonstrated that the compounds blocked acetylcholine (ACh)-evoked responses in Xenopus laevis oocytes expressing the adult nAChR composed of αβ𝜀δ subunits in a concentration-dependent manner, with a ranked potency of quinine (IC50 = 1.70 **M), chloroquine (IC50 = 2.22 **M) and quinidine (IC50 = 3.96 **M). At the fetal nAChR composed of ** subunits, the IC50 for quinine was found to be 2.30 **M. The efficacy of the block by quinine was independent of the ACh concentration. Therefore, quinine is proposed to inhibit ACh-evoked currents in a non-competitive manner. The present results add to the pharmacological characterization of muscle nAChRs and indicate that quinine is effective at the muscular nAChRs close to therapeutic blood concentrations required for the therapy and prophylaxis of nocturnal leg cramps, suggesting that the clinically proven efficacy of quinine could be based on targeting nAChRs.</AbstractText></Abstract>"""

print(fromstring(s))
Post not yet marked as solved Up vote post of flintrider Down vote post of flintrider
394 views

Replies

What error are you getting? When I tried this with the built-in Python [1], it complains that the lxml is missing.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

[1] macOS has no built-in Python; I’m using the Python 3 that comes bundled in Xcode.

  • @eskimo Yes. lxml is missing. You have to do pip install lxml. My concern is that, this code shows me error but when I run in Linux/Windows, It works fine.

    Error: lxml.etree.XMLSyntaxError: Char 0x0 out of allowed range, line 1, column 2. If this is the error, then why the same code doesn't shows any error on linux? Is this because of CPU arch?

Add a Comment