PyO3 / pyo3

Rust bindings for the Python interpreter
https://pyo3.rs
Other
11.87k stars 728 forks source link

Question about enviroment problems when compiling pyo3 #1105

Closed PosoSAgapo closed 3 years ago

PosoSAgapo commented 4 years ago

🌍 Environment

πŸ’₯ Reproducing

Firstly I meet an encoding problem that was described in this issue , which shows setting a PYTHONHOME and PYTHONPATH enviroment variable could solve this problem. Then I use where python in shell to show the python directory and then add it to the .zshrc and sourced .zshrc after I edited this file, now my enviroment variable setting is like below:

COLORFGBG='7;0' CONDA_EXE=/opt/anaconda3/bin/conda CONDA_PYTHON_EXE=/opt/anaconda3/bin/python CONDA_SHLVL=0 HOME=/Users/chenbowen PATH=/Library/PostgreSQL/12/bin/:/Library/PostgreSQL/12/bin/:/Library/PostgreSQL/12/bin/:/Library/PostgreSQL/12/bin/:/opt/anaconda3/condabin:/Library/PostgreSQL/12/bin/:/Users/chenbowen/.cargo/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin PYTHONHOME=/opt/anaconda3/bin/ PYTHONPATH=/opt/anaconda3/bin/python SHELL=/bin/zsh SHLVL=1 TERM=xterm-256color TERM_PROGRAM=iTerm.app TERM_PROGRAM_VERSION=3.3.12 TERM_SESSION_ID=w0t0p2:B6B4E9AF-EC25-4E89-BA79-47E45AC88D0D TMPDIR=/var/folders/ql/nyyhlh8s3wn5f7g7623wkppc0000gn/T/ XPC_FLAGS=0x0 XPC_SERVICE_NAME=0 _CE_CONDA='' _CE_M=''

Then encoding problem was solved but any another problem occured when I was using sudo cargo +nightly build:

error: linking with cc failed: exit code: 1 = note: "cc" "-m64" "-L" "/Users/chenbowen/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib" "/Users/chenbowen/CLionProjects/ruststudy/target/debug/deps/ruststudy.140i76tvprhi8724.rcgu.o" "/Users/chenbowen/CLionProjects/ruststudy/target/debug/deps/ruststudy.141c50u9cbyjuzrz.rcgu.o" "/Users/chenbowen/CLionProjects/ruststudy/target/debug/deps/ruststudy.15k44jvacwnpyohf.rcgu.o" "/Users/chenbowen/CLionProjects/ruststudy/target/debug/deps/ruststudy.1e8qmcakbzj7kqf2.rcgu.o" "/Users/chenbowen/CLionProjects/ruststudy/target/debug/deps/ruststudy.1htfksy4nzig3vhq.rcgu.o" "/Users/chenbowen/CLionProjects/ruststudy/target/debug/deps/ruststudy.22xjn16u6a3okpgc.rcgu.o" "/Users/chenbowen/CLionProjects/ruststudy/target/debug/deps/ruststudy.2h03t0wv2g1cda3f.rcgu.o" "/Users/chenbowen/CLionProjects/ruststudy/target/debug/deps/ruststudy.2q5h9k0ob4g97ll1.rcgu.o" "/Users/chenbowen/CLionProjects/ruststudy/target/debug/deps/ruststudy.34d6lk85be6lbol8.rcgu.o" "/Users/chenbowen/CLionProjects/ruststudy/target/debug/deps/ruststudy.3baxicgouixw4jm.rcgu.o" "/Users/chenbowen/CLionProjects/ruststudy/target/debug/deps/ruststudy.3deoqsechef1rfri.rcgu.o" "/Users/chenbowen/CLionProjects/ruststudy/target/debug/deps/ruststudy.3ov05jl1druft6ti.rcgu.o" "/Users/chenbowen/CLionProjects/ruststudy/target/debug/deps/ruststudy.3tanyi723f8d6qxp.rcgu.o" "/Users/chenbowen/CLionProjects/ruststudy/target/debug/deps/ruststudy.3v54iupt5uc7iuuu.rcgu.o" "/Users/chenbowen/CLionProjects/ruststudy/target/debug/deps/ruststudy.3vgdw8p4zqojlohw.rcgu.o" "/Users/chenbowen/CLionProjects/ruststudy/target/debug/deps/ruststudy.47rtwdzmq8vrfb9e.rcgu.o" "/Users/chenbowen/CLionProjects/ruststudy/target/debug/deps/ruststudy.4chae59e0sf56wnu.rcgu.o" "/Users/chenbowen/CLionProjects/ruststudy/target/debug/deps/ruststudy.4x243lze9pb2imcl.rcgu.o" "/Users/chenbowen/CLionProjects/ruststudy/target/debug/deps/ruststudy.54oyjxhls9ctawng.rcgu.o" "/Users/chenbowen/CLionProjects/ruststudy/target/debug/deps/ruststudy.55g1cxy8pwkjxv8e.rcgu.o" "/Users/chenbowen/CLionProjects/ruststudy/target/debug/deps/ruststudy.5dra31keg7bdjydk.rcgu.o" "/Users/chenbowen/CLionProjects/ruststudy/target/debug/deps/ruststudy.9qhwtfyoncmqliy.rcgu.o" "/Users/chenbowen/CLionProjects/ruststudy/target/debug/deps/ruststudy.q6qwsi9yn9jch2g.rcgu.o" "/Users/chenbowen/CLionProjects/ruststudy/target/debug/deps/ruststudy.uoao78mf7hb130b.rcgu.o" "-o" "/Users/chenbowen/CLionProjects/ruststudy/target/debug/deps/ruststudy" "/Users/chenbowen/CLionProjects/ruststudy/target/debug/deps/ruststudy.31ofrb0z424v72al.rcgu.o" "-Wl,-dead_strip" "-nodefaultlibs" "-L" "/Users/chenbowen/CLionProjects/ruststudy/target/debug/deps" "-L" "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.7/lib" "-L" "/Users/chenbowen/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib" "/Users/chenbowen/CLionProjects/ruststudy/target/debug/deps/libpyo3-f07d758f48232337.rlib" "/Users/chenbowen/CLionProjects/ruststudy/target/debug/deps/libparking_lot-bcfd76020e0653e3.rlib" "/Users/chenbowen/CLionProjects/ruststudy/target/debug/deps/libparking_lot_core-bba55b27ed443046.rlib" "/Users/chenbowen/CLionProjects/ruststudy/target/debug/deps/libsmallvec-ff409f469bbbdf5e.rlib" "/Users/chenbowen/CLionProjects/ruststudy/target/debug/deps/libcfg_if-99a1c55ab49a4433.rlib" "/Users/chenbowen/CLionProjects/ruststudy/target/debug/deps/liblock_api-0764144bcd8559cd.rlib" "/Users/chenbowen/CLionProjects/ruststudy/target/debug/deps/libscopeguard-fa0a164027cbd96c.rlib" "/Users/chenbowen/CLionProjects/ruststudy/target/debug/deps/libinstant-af8bca8197487044.rlib" "/Users/chenbowen/CLionProjects/ruststudy/target/debug/deps/liblibc-2a7c42407beac51f.rlib" "/Users/chenbowen/CLionProjects/ruststudy/target/debug/deps/libunindent-ebcf874e879c5218.rlib" "/Users/chenbowen/CLionProjects/ruststudy/target/debug/deps/libpaste-e880ea718b2c44be.rlib" "/Users/chenbowen/CLionProjects/ruststudy/target/debug/deps/libinventory-60f4ffd535ab00d3.rlib" "/Users/chenbowen/CLionProjects/ruststudy/target/debug/deps/libindoc-3d350b3c5125e618.rlib" "/Users/chenbowen/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libstd-473bfa6649025a67.rlib" "/Users/chenbowen/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libpanic_unwind-8e1c1c2f3b88fa26.rlib" "/Users/chenbowen/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libhashbrown-73b777ace327e6f8.rlib" "/Users/chenbowen/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/librustc_std_workspace_alloc-b666c9c30cd05ed8.rlib" "/Users/chenbowen/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libbacktrace-13799bdb379be2ce.rlib" "/Users/chenbowen/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libbacktrace_sys-63abd5899e0d7e6b.rlib" "/Users/chenbowen/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/librustc_demangle-1b07ed0286619776.rlib" "/Users/chenbowen/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libunwind-89188c3232051162.rlib" "/Users/chenbowen/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcfg_if-caece456e5f78fce.rlib" "/Users/chenbowen/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/liblibc-628a35dcde52dad2.rlib" "/Users/chenbowen/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/liballoc-a0fac8d46f97ec7a.rlib" "/Users/chenbowen/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/librustc_std_workspace_core-ef5998790eeac756.rlib" "/Users/chenbowen/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcore-3fe78a4d2924ae43.rlib" "/Users/chenbowen/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcompiler_builtins-e166c2d904273814.rlib" "-lpython3.7m" "-lSystem" "-lresolv" "-lc" "-lm" = note: ld: warning: directory not found for option '-L/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.7/lib' ld: library not found for -lpython3.7m clang: error: linker command failed with exit code 1 (use -v to see invocation)

But the error is sightly different when I typing cargo +nightly run without sudo:

error: could not write output to /Users/chenbowen/CLionProjects/ruststudy/target/debug/deps/ruststudy.31ofrb0z424v72al.rcgu.o: Permission denied error: aborting due to previous error error: could not compile ruststudy.

I was struggling about this for several days and do not quite know the exact reason that causes this problem, since the first problem was caused by enviroment variable setting. I guess the problem might still is about enviroment variable, but I did not see that my configuration was wrong.

programmerjake commented 4 years ago

the error you get when running without sudo is likely caused by the files in target being owned by root. try running

sudo rm -rf /Users/chenbowen/CLionProjects/ruststudy/target

which will delete your target directory, then you should be able to get it to work without using sudo (perhaps with some additional work).

davidhewitt commented 4 years ago

^ As jake says regarding the sudo issue.

If you're still having issues after that, can you please run the print-info example from this repository: https://github.com/davidhewitt/python-config, and paste the output here? That can help us to diagnose any issues easier.

PosoSAgapo commented 4 years ago

the error you get when running without sudo is likely caused by the files in target being owned by root. try running

sudo rm -rf /Users/chenbowen/CLionProjects/ruststudy/target

which will delete your target directory, then you should be able to get it to work without using sudo (perhaps with some additional work).

Sincerely thank you for your reply, I tried using your command then use run in CLion which will build the project firstly, but the problem is still here in the same way. What does the target directory do in a project? Would this be a problem that caused by the conflict between anaconda python and system default python?

davidhewitt commented 4 years ago

The target directory is where cargo puts all output. When you ran sudo cargo this would have created that directory as the root user, which is why you had permission trouble after that.

PosoSAgapo commented 4 years ago

The target directory is where cargo puts all output. When you ran sudo cargo this would have created that directory as the root user, which is why you had permission trouble after that.

Thank you for you detailed explanation, I runed the 'python-config' project and it gives below information:

thread 'main' panicked at 'no entry found for key', /Users/chenbowen/Desktop/python-config-master/src/lib.rs:50:20 stack backtrace: 0: backtrace::backtrace::libunwind::trace at /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/libunwind.rs:86 1: backtrace::backtrace::trace_unsynchronized at /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/mod.rs:66 2: std::sys_common::backtrace::_print_fmt at src/libstd/sys_common/backtrace.rs:78 3: ::fmt at src/libstd/sys_common/backtrace.rs:59 4: core::fmt::write at src/libcore/fmt/mod.rs:1076 5: std::io::Write::write_fmt at src/libstd/io/mod.rs:1537 6: std::sys_common::backtrace::_print at src/libstd/sys_common/backtrace.rs:62 7: std::sys_common::backtrace::print at src/libstd/sys_common/backtrace.rs:49 8: std::panicking::default_hook::{{closure}} at src/libstd/panicking.rs:198 9: std::panicking::default_hook at src/libstd/panicking.rs:217 10: std::panicking::rust_panic_with_hook at src/libstd/panicking.rs:526 11: rust_begin_unwind at src/libstd/panicking.rs:437 12: core::panicking::panic_fmt at src/libcore/panicking.rs:85 13: core::option::expect_failed at src/libcore/option.rs:1261 14: core::option::Option::expect at /Users/chenbowen/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/src/libcore/option.rs:344 15: <std::collections::hash::map::HashMap<K,V,S> as core::ops::index::Index<&Q>>::index at /Users/chenbowen/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/src/libstd/collections/hash/map.rs:1034 16: python_config::get_config_from_interpreter at ./src/lib.rs:50 17: python_config::find_interpreters::{{closure}} at ./src/lib.rs:149 18: core::ops::function::impls::<impl core::ops::function::FnMut for &mut F>::call_mut at /Users/chenbowen/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/src/libcore/ops/function.rs:275 19: <core::slice::Iter as core::iter::traits::iterator::Iterator>::find_map at /Users/chenbowen/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/src/libcore/slice/mod.rs:3572 20: <core::iter::adapters::FilterMap<I,F> as core::iter::traits::iterator::Iterator>::next at /Users/chenbowen/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/src/libcore/iter/adapters/mod.rs:1132 21: print_info::find_interpreter at examples/print_info.rs:4 22: print_info::main at examples/print_info.rs:14 23: std::rt::lang_start::{{closure}} at /Users/chenbowen/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/src/libstd/rt.rs:67 24: std::rt::lang_start_internal::{{closure}} at src/libstd/rt.rs:52 25: std::panicking::try::do_call at src/libstd/panicking.rs:348 26: std::panicking::try at src/libstd/panicking.rs:325 27: std::panic::catch_unwind at src/libstd/panic.rs:394 28: std::rt::lang_start_internal at src/libstd/rt.rs:51 29: std::rt::lang_start at /Users/chenbowen/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/src/libstd/rt.rs:67 30: main note: Some details are omitted, run with RUST_BACKTRACE=full for a verbose backtrace.

Should I run with RUST_BACKTRACE=full to get a verbose backtrace?

PosoSAgapo commented 4 years ago

Additionally, when I set PYTHONHOME and PYTHONPATH as enviroment variable, the anaconda python was disabled which the anacodna python enviroment cannot not be automatically activated when starts a new shell after I set the enviroment variable.

Then the system python could only be called using sudo command

Run pure 'python' which would call the system default python2 would give:

ImportError: No module named site

Run 'python3' which would use default python3 of OSX would give encoding error again!

Fatal Python error: initfsencoding: unable to load the file system codec, sys.path = ['/opt/anaconda3/bin/python', '/opt/anaconda3/bin/lib/python37.zip', '/opt/anaconda3/bin/lib/python3.7', '/opt/anaconda3/bin/lib/python3.7/lib-dynload'] ModuleNotFoundError: No module named 'encodings'

Only sudo command could make system python3 or python work again, I guess this phenomenon is related to this problem in here, but I do not know the connection between them.

davidhewitt commented 4 years ago

No, that backtrace is enough. Something's very strange with your python setup...!

I can't help more today, but I will update python-config over the weekend to try to help diagnose your setup. I'll post back here when I've got a new version for you to try.

PosoSAgapo commented 4 years ago

No, that backtrace is enough. Something's very strange with your python setup...!

I can't help more today, but I will update python-config over the weekend to try to help diagnose your setup. I'll post back here when I've got a new version for you to try.

Thank you so much, this problem has troubled me for several days and I could not find answer in the internet.

davidhewitt commented 4 years ago

If I had to make a guess though, this part of your PATH might be wrong:

/opt/anaconda3/condabin

what happens if you change that to

/opt/anaconda3/bin

?

Presumably you set that via .zshrc ?

PosoSAgapo commented 4 years ago

If I had to make a guess though, this part of your PATH might be wrong:

/opt/anaconda3/condabin

what happens if you change that to

/opt/anaconda3/bin

?

Presumably you set that via .zshrc ?

This path was actually done when installing anaconda3 which will automatically initialize the enviroment variable that relates to anacodna python, I will edit it and see what happens.

PosoSAgapo commented 4 years ago

Changing the anaconda enviroment variable did not make things right, but running this project in shell and in IDE gives different output, in shell running 'cargo run' it still gives encodings problem but in a IDE like CLion, cliking run button would give

error: linking with cc failed: exit code: 1 | = note: "cc" "-m64" "-L" "/Users/chenbowen/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib" "/Users/chenbowen/CLionProjects/ruststudy/target/debug/deps/ruststudy.140i76tvprhi8724.rcgu.o" "/Users/chenbowen/CLionProjects/ruststudy/target/debug/deps/ruststudy.141c50u9cbyjuzrz.rcgu.o" "/Users/chenbowen/CLionProjects/ruststudy/target/debug/deps/ruststudy.15k44jvacwnpyohf.rcgu.o" "/Users/chenbowen/CLionProjects/ruststudy/target/debug/deps/ruststudy.1e8qmcakbzj7kqf2.rcgu.o" "/Users/chenbowen/CLionProjects/ruststudy/target/debug/deps/ruststudy.1htfksy4nzig3vhq.rcgu.o" "/Users/chenbowen/CLionProjects/ruststudy/target/debug/deps/ruststudy.22xjn16u6a3okpgc.rcgu.o" "/Users/chenbowen/CLionProjects/ruststudy/target/debug/deps/ruststudy.2h03t0wv2g1cda3f.rcgu.o" "/Users/chenbowen/CLionProjects/ruststudy/target/debug/deps/ruststudy.2q5h9k0ob4g97ll1.rcgu.o" "/Users/chenbowen/CLionProjects/ruststudy/target/debug/deps/ruststudy.34d6lk85be6lbol8.rcgu.o" "/Users/chenbowen/CLionProjects/ruststudy/target/debug/deps/ruststudy.3baxicgouixw4jm.rcgu.o" "/Users/chenbowen/CLionProjects/ruststudy/target/debug/deps/ruststudy.3deoqsechef1rfri.rcgu.o" "/Users/chenbowen/CLionProjects/ruststudy/target/debug/deps/ruststudy.3ov05jl1druft6ti.rcgu.o" "/Users/chenbowen/CLionProjects/ruststudy/target/debug/deps/ruststudy.3tanyi723f8d6qxp.rcgu.o" "/Users/chenbowen/CLionProjects/ruststudy/target/debug/deps/ruststudy.3v54iupt5uc7iuuu.rcgu.o" "/Users/chenbowen/CLionProjects/ruststudy/target/debug/deps/ruststudy.3vgdw8p4zqojlohw.rcgu.o" "/Users/chenbowen/CLionProjects/ruststudy/target/debug/deps/ruststudy.47rtwdzmq8vrfb9e.rcgu.o" "/Users/chenbowen/CLionProjects/ruststudy/target/debug/deps/ruststudy.4chae59e0sf56wnu.rcgu.o" "/Users/chenbowen/CLionProjects/ruststudy/target/debug/deps/ruststudy.4x243lze9pb2imcl.rcgu.o" "/Users/chenbowen/CLionProjects/ruststudy/target/debug/deps/ruststudy.54oyjxhls9ctawng.rcgu.o" "/Users/chenbowen/CLionProjects/ruststudy/target/debug/deps/ruststudy.55g1cxy8pwkjxv8e.rcgu.o" "/Users/chenbowen/CLionProjects/ruststudy/target/debug/deps/ruststudy.5dra31keg7bdjydk.rcgu.o" "/Users/chenbowen/CLionProjects/ruststudy/target/debug/deps/ruststudy.9qhwtfyoncmqliy.rcgu.o" "/Users/chenbowen/CLionProjects/ruststudy/target/debug/deps/ruststudy.q6qwsi9yn9jch2g.rcgu.o" "/Users/chenbowen/CLionProjects/ruststudy/target/debug/deps/ruststudy.uoao78mf7hb130b.rcgu.o" "-o" "/Users/chenbowen/CLionProjects/ruststudy/target/debug/deps/ruststudy" "/Users/chenbowen/CLionProjects/ruststudy/target/debug/deps/ruststudy.31ofrb0z424v72al.rcgu.o" "-Wl,-dead_strip" "-nodefaultlibs" "-L" "/Users/chenbowen/CLionProjects/ruststudy/target/debug/deps" "-L" "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.7/lib" "-L" "/Users/chenbowen/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib" "/Users/chenbowen/CLionProjects/ruststudy/target/debug/deps/libpyo3-f07d758f48232337.rlib" "/Users/chenbowen/CLionProjects/ruststudy/target/debug/deps/libparking_lot-bcfd76020e0653e3.rlib" "/Users/chenbowen/CLionProjects/ruststudy/target/debug/deps/libparking_lot_core-bba55b27ed443046.rlib" "/Users/chenbowen/CLionProjects/ruststudy/target/debug/deps/libsmallvec-ff409f469bbbdf5e.rlib" "/Users/chenbowen/CLionProjects/ruststudy/target/debug/deps/libcfg_if-99a1c55ab49a4433.rlib" "/Users/chenbowen/CLionProjects/ruststudy/target/debug/deps/liblock_api-0764144bcd8559cd.rlib" "/Users/chenbowen/CLionProjects/ruststudy/target/debug/deps/libscopeguard-fa0a164027cbd96c.rlib" "/Users/chenbowen/CLionProjects/ruststudy/target/debug/deps/libinstant-af8bca8197487044.rlib" "/Users/chenbowen/CLionProjects/ruststudy/target/debug/deps/liblibc-2a7c42407beac51f.rlib" "/Users/chenbowen/CLionProjects/ruststudy/target/debug/deps/libunindent-ebcf874e879c5218.rlib" "/Users/chenbowen/CLionProjects/ruststudy/target/debug/deps/libpaste-e880ea718b2c44be.rlib" "/Users/chenbowen/CLionProjects/ruststudy/target/debug/deps/libinventory-60f4ffd535ab00d3.rlib" "/Users/chenbowen/CLionProjects/ruststudy/target/debug/deps/libindoc-3d350b3c5125e618.rlib" "/Users/chenbowen/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libstd-473bfa6649025a67.rlib" "/Users/chenbowen/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libpanic_unwind-8e1c1c2f3b88fa26.rlib" "/Users/chenbowen/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libhashbrown-73b777ace327e6f8.rlib" "/Users/chenbowen/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/librustc_std_workspace_alloc-b666c9c30cd05ed8.rlib" "/Users/chenbowen/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libbacktrace-13799bdb379be2ce.rlib" "/Users/chenbowen/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libbacktrace_sys-63abd5899e0d7e6b.rlib" "/Users/chenbowen/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/librustc_demangle-1b07ed0286619776.rlib" "/Users/chenbowen/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libunwind-89188c3232051162.rlib" "/Users/chenbowen/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcfg_if-caece456e5f78fce.rlib" "/Users/chenbowen/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/liblibc-628a35dcde52dad2.rlib" "/Users/chenbowen/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/liballoc-a0fac8d46f97ec7a.rlib" "/Users/chenbowen/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/librustc_std_workspace_core-ef5998790eeac756.rlib" "/Users/chenbowen/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcore-3fe78a4d2924ae43.rlib" "/Users/chenbowen/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcompiler_builtins-e166c2d904273814.rlib" "-lpython3.7m" "-lSystem" "-lresolv" "-lc" "-lm" = note: ld: warning: directory not found for option '-L/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.7/lib' ld: library not found for -lpython3.7m clang: error: linker command failed with exit code 1 (use -v to see invocation)

Which has different outputs, I wonder what could cause the error message not being the same when running in shell and IDE?

davidhewitt commented 4 years ago

Apologies, didn't get around to this on the weekend; I'll try to add the patch to python-config at some point in the coming week.

Regarding your different error messages in shell vs IDE - I guess they have different environment variables? You may want to check your IDE configuration, because I think it won't use your .zshrc by default.

PosoSAgapo commented 4 years ago
  • I guess they

Thank you for your reply. The IDE configuration is the same. I would like to know how the rust calls the python? Maybe it find a python but cannot find its related packages that may be used to initialize?

davidhewitt commented 3 years ago

@PosoSAgapo sorry for the delay in fixing python-config - I've now just updated it. If you're still experiencing this issue, do you want to try the updated python-config and paste the output here?

davidhewitt commented 3 years ago

As there has been no response on this question for some time, I'm going to close it. Thank you for the discussion.