Skip to content
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

Importing Python random lead to an error #762

Closed
maximdanilchenko opened this issue Feb 10, 2020 · 6 comments · Fixed by #1347
Closed

Importing Python random lead to an error #762

maximdanilchenko opened this issue Feb 10, 2020 · 6 comments · Fixed by #1347
Assignees

Comments

@maximdanilchenko
Copy link

Hi!

🌍 Environment

  • Your operating system and version:

macOS Mojave 10.14.6

  • Your python version:

Tested on 3.8.1 and 3.6.10

  • How did you install python (e.g. apt or pyenv)? Did you use a virtualenv?:

I use pyenv

  • Your rust version (rustc --version):

rustc 1.43.0-nightly (58b834344 2020-02-05)

  • Are you using the latest pyo3 version? Have you tried using latest master?

0.8.4 and master both have this issue

💥 Reproducing

fn main(){
    let gil = Python::acquire_gil();
    let py = gil.python();
    match py.import("random") {
            Err(e) => e.print(py),
            Ok(x) => {},
        }
}
Traceback (most recent call last):
  File "/Users/maksim.danilchenko/.pyenv/versions/3.6.10/lib/python3.6/random.py", line 42, in <module>
    from math import log as _log, exp as _exp, pi as _pi, e as _e, ceil as _ceil
ImportError: dlopen(/Users/maksim.danilchenko/.pyenv/versions/3.6.10/lib/python3.6/lib-dynload/math.cpython-36m-darwin.so, 2): Symbol not found: __PyLong_GCD
  Referenced from: /Users/maksim.danilchenko/.pyenv/versions/3.6.10/lib/python3.6/lib-dynload/math.cpython-36m-darwin.so
  Expected in: flat namespace
 in /Users/maksim.danilchenko/.pyenv/versions/3.6.10/lib/python3.6/lib-dynload/math.cpython-36m-darwin.so
@maximdanilchenko
Copy link
Author

#742 (comment) - fixes it, but anyway it is not common way to Install pyenv:)

@kngwyu
Copy link
Member

kngwyu commented Feb 11, 2020

Thank you!
I'll add a note for this on README and the guide.

@movermeyer
Copy link

movermeyer commented Mar 28, 2020

It may be obvious, but this isn't limited to random. You can also reproduce it with datetime, and math.

Traceback (most recent call last):
  File "/Users/my_user/.pyenv/versions/3.8.0/lib/python3.8/datetime.py", line 8, in <module>
    import math as _math
ImportError: dlopen(/Users/my_user/.pyenv/versions/3.8.0/lib/python3.8/lib-dynload/math.cpython-38-darwin.so, 2): Symbol not found: __PyLong_GCD
  Referenced from: /Users/my_user/.pyenv/versions/3.8.0/lib/python3.8/lib-dynload/math.cpython-38-darwin.so
  Expected in: flat namespace

@kngwyu
Copy link
Member

kngwyu commented Mar 28, 2020

I'm still not sure how to deal with pyenv problem.
@movermeyer
If you have any idea, please comment to #763

@davidhewitt
Copy link
Member

I am wondering whether it's possible to detect a misconfigured pyenv in build.rs.

I have MBP I can use to test sometime. No promises on exactly when.

@davidhewitt davidhewitt self-assigned this Mar 28, 2020
@ethanhs
Copy link
Contributor

ethanhs commented May 2, 2020

The sysconfig module CONFIG_ARGS variable has the command line, so it seems simple to check if that contains "--enable-shared"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants