Python shell和Python参数中的不同输出(xx年)

2024-10-01 02:30:46 发布

您现在位置:Python中文网/ 问答频道 /正文

我的python解释器是:

(base) ➜  ~ which python
/home/markd/anaconda3/bin/python

我通过conda install -c conda-forge umap-learn安装了UMAP,然后在pythonshell中运行良好,例如

(base) ➜  ~ python
Python 3.7.4 (default, Aug 13 2019, 20:35:49) 
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import umap
>>> print(umap.__version__)
0.3.10

但是,如果运行python testumap.pypython -u testumap.py,则失败:

(base) ➜  ~ cat testumap.py
import umap
print(umap.__version__)
(base) ➜  ~ python testumap.py
Traceback (most recent call last):
  File "testumap.py", line 1, in <module>
    import umap
  File "testumap.py", line 2, in <module>
    print(umap.__version__)
AttributeError: module 'umap' has no attribute '__version__'

我不知道怎么了。是因为康达还是UMAP?你知道吗

我尝试导入和打印其他已安装库的版本,它们在pythonshell或Python参数(Python)中显示相同的输出xxx年). 你知道吗


Tags: inpyimportbaseversionline解释器conda