sys.path will use user site-packages over the environment's site-packages
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Cần làm rõ
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- python
- Lĩnh vực
- build-system
Hướng nghiên cứu
Tái hiện hành vi được báo cáo bằng cách kiểm tra sys.path trong cả root và một môi trường conda mới, sử dụng thiết lập user-site và các lệnh được nêu trong issue. Đọc PEP 370 và các điểm vào khởi tạo Python site-path; hoàn tất khi site-packages của môi trường không bị user site-packages che khuất ngoài dự kiến.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Hello,
I'm following up on a recommendation from @jakirkham in the R-base feedstock in this issue:
https://github.com/conda-forge/r-base-feedstock/issues/37 where we see similar behavior in R with respect to .libPaths().
According to PEP 370 there are platform-specific paths in which users can install packages which will be included in sys.path. The unfortunate result is that if you have a package installed there, it may be incompatible with a given conda environment's binaries and cause issues. Worse, the user-package is always preferred in import-order, so this will impact every environment (including root).
I'm kind of torn as to whether this is or is not a bug, but I'm reporting it in any case for further discussion.
Here is a demonstration showing this in a root environment from defaults and a conda-forge environment using the Python from this feedstock.
boring conda-info for completeness
16:33:55 ~
§ conda info
active environment : None
user config file : /home/evan/.condarc
populated config files :
conda version : 4.4.11
conda-build version : 3.0.28
python version : 3.6.1.final.0
base environment : /opt/Miniconda3 (read only)
channel URLs : https://repo.continuum.io/pkgs/main/linux-64
https://repo.continuum.io/pkgs/main/noarch
https://repo.continuum.io/pkgs/free/linux-64
https://repo.continuum.io/pkgs/free/noarch
https://repo.continuum.io/pkgs/r/linux-64
https://repo.continuum.io/pkgs/r/noarch
https://repo.continuum.io/pkgs/pro/linux-64
https://repo.continuum.io/pkgs/pro/noarch
package cache : /opt/Miniconda3/pkgs
/home/evan/.conda/pkgs
envs directories : /home/evan/.conda/envs
/opt/Miniconda3/envs
platform : linux-64
user-agent : conda/4.4.11 requests/2.14.2 CPython/3.6.1 Linux/4.15.7-1-ARCH arch/ glibc/2.26
UID:GID : 1000:100
netrc file : None
offline mode : False
Set up the user-site packages and add a Hello World package:
16:33:59 ~
§ mkdir -p ~/.local/lib/python3.6/site-packages
16:34:07 ~
§ echo "print('Hello World')" > ~/.local/lib/python3.6/site-packages/hello.py
Try it in the root environment:
16:34:13 ~
§ which python
/opt/Miniconda3/bin/python
16:34:20 ~
§ python
Python 3.6.1 |Continuum Analytics, Inc.| (default, May 11 2017, 13:09:58)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path
['', '/opt/Miniconda3/lib/python36.zip', '/opt/Miniconda3/lib/python3.6', '/opt/Miniconda3/lib/python3.6/lib-dynload', '/home/evan/.local/lib/python3.6/site-packages', '/opt/Miniconda3/lib/python3.6/site-packages']
>>>
>>> import hello
Hello World
>>>
Note the end of sys.path: '/home/evan/.local/lib/python3.6/site-packages', '/opt/Miniconda3/lib/python3.6/site-packages'] the .local site-packages takes precedence over the environment's.
Try it in a fresh conda-forge environment:
16:34:40 ~
§ conda create -n example -c conda-forge python=3.6
Boring output of install plan
Solving environment: done
## Package Plan ##
environment location: /home/evan/.conda/envs/example
added / updated specs:
- python=3.6
The following packages will be downloaded:
package | build
---------------------------|-----------------
certifi-2018.1.18 | py36_0 143 KB conda-forge
setuptools-38.5.2 | py36_0 525 KB conda-forge
------------------------------------------------------------
Total: 668 KB
The following NEW packages will be INSTALLED:
ca-certificates: 2018.1.18-0 conda-forge
certifi: 2018.1.18-py36_0 conda-forge
ncurses: 5.9-10 conda-forge
openssl: 1.0.2n-0 conda-forge
pip: 9.0.1-py36_1 conda-forge
python: 3.6.4-0 conda-forge
readline: 7.0-0 conda-forge
setuptools: 38.5.2-py36_0 conda-forge
sqlite: 3.20.1-2 conda-forge
tk: 8.6.7-0 conda-forge
wheel: 0.30.0-py36_2 conda-forge
xz: 5.2.3-0 conda-forge
zlib: 1.2.11-0 conda-forge
Proceed ([y]/n)? y
Downloading and Extracting Packages
certifi 2018.1.18: ##################################################### | 100%
setuptools 38.5.2: ##################################################### | 100%
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
#
# To activate this environment, use:
# > source activate example
#
# To deactivate an active environment, use:
# > source deactivate
#
Run the same test:
16:35:21 ~
§ source activate example
(example) 16:35:27 ~
§ which python
/home/evan/.conda/envs/example/bin/python
(example) 16:35:29 ~
§ python
Python 3.6.4 | packaged by conda-forge | (default, Dec 23 2017, 16:31:06)
[GCC 4.8.2 20140120 (Red Hat 4.8.2-15)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path
['', '/home/evan/.conda/envs/example/lib/python36.zip', '/home/evan/.conda/envs/example/lib/python3.6', '/home/evan/.conda/envs/example/lib/python3.6/lib-dynload', '/home/evan/.local/lib/python3.6/site-packages', '/home/evan/.conda/envs/example/lib/python3.6/site-packages']
>>>
>>> import hello
Hello World
>>>
Same behavior for .local site-packages as in root.
- Ngôn ngữ chính
- Shell
- Star
- 47
- Fork
- 112
- Merge trung bình
- 22 giờ 18 phút
- Pull request đã merge (30 ngày)
- 14
Chuẩn bị môi trường
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của conda-forge/python-feedstock
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
conda-forge/python-feedstock#934 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 48/100
conda-forge/python-feedstock#929 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
conda-forge/python-feedstock#903 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
conda-forge/python-feedstock#880 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 58/100
conda-forge/python-feedstock#879 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của conda-forge/python-feedstock
Issue tương tự
-
bot-found bug priority: P3
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
madenvel/KalinkaPlayer#179 ·
-
[platform-assessment 2026-09]Đang mởdocumentation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
jbaruch/coding-policy#621 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
mattpocock/skills#1134 ·
-
area:build bug P3
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 92/100
uttrflow/uttrflow-swift#2506 ·
Maintainer thường phản hồi trong vòng 1 ngày