简体   繁体   English

是否可以从 Anaconda 将 numpy 导入 Python 3.9?

[英]Is it possible to import numpy to Python 3.9 from Anaconda?

I have a question about using numpy library.我有一个关于使用 numpy 库的问题。 A couple of months ago, I downloaded Anaconda, which gives numpy automatically.几个月前,我下载了 Anaconda,它会自动提供 numpy。 I am trying to use numpy by importing from ANaconda to Python.我正在尝试通过从 ANaconda 导入到 Python 来使用 numpy。 WHat I have done is: I added the package of numpy from Anaconda folder to Python folder.我所做的是:我将 numpy 的 package 从 Anaconda 文件夹添加到 ZA7F5F5FC39231B562871B54231 However, the python shell says that但是,python shell 说

  File "C:\Users\Alice Jun\Desktop\Python 3.9\numpy\core\__init__.py", line 22, in <module>
    from . import multiarray
  File "C:\Users\Alice Jun\Desktop\Python 3.9\numpy\core\multiarray.py", line 12, in <module>
    from . import overrides
  File "C:\Users\Alice Jun\Desktop\Python 3.9\numpy\core\overrides.py", line 7, in <module>
    from numpy.core._multiarray_umath import (
ModuleNotFoundError: No module named 'numpy.core._multiarray_umath'

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "C:\Users\Alice Jun\Desktop\Python 3.9\gui.py", line 2, in <module>
        import numpy as np
      File "C:\Users\Alice Jun\Desktop\Python 3.9\numpy\__init__.py", line 140, in <module>
        from . import core
      File "C:\Users\Alice Jun\Desktop\Python 3.9\numpy\core\__init__.py", line 48, in <module>
        raise ImportError(msg)

What should I do to import numpy?导入 numpy 应该怎么做? Thank you and stay safe!谢谢你,保持安全!

As others mentioned, that is not a proper way of installing a package.正如其他人所提到的,这不是安装 package 的正确方法。 You are making a copy anyway, so install it through proper routes, eg,无论如何,您都在制作副本,因此请通过适当的路线安装它,例如,

# where `python` is the one you wish to use
python -m pip install numpy

Otherwise, the reason why what OP shows did not work is because packages are located under a site-packages directory (search under your Python 3.9/ directory. If one really wants to manually install a package, that's where it goes.否则,OP 显示不起作用的原因是因为软件包位于site-packages目录下(在Python 3.9/目录下搜索。如果真的想手动安装 package,那就是它的去处。

However, be aware that Conda packages make heavy use of dynamic linking in order to minimize redundancy of common dependencies.但是,请注意,Conda 包大量使用动态链接以最大程度地减少常见依赖项的冗余。 This is often done through @rpath specifications, which means moving packages out of their Conda environment path will frequently result in non-functionality.这通常是通过@rpath 规范完成的,这意味着将包移出它们的 Conda 环境路径通常会导致无法运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM