anaconda创建了虚拟python环境,且安装了pytorch,但是pycharm中import torch运行时报错

报错如下:

C:\Users\tashi\.conda\envs\test1\python.exe D:\project\python\transformer\main.py 
C:\Users\tashi\.conda\envs\test1\lib\site-packages\numpy\__init__.py:127: UserWarning: mkl-service package failed to import, therefore Intel(R) MKL initialization ensuring its correct out-of-the box operation under condition when Gnu OpenMP had already been loaded by Python process is not assured. Please install mkl-service package, see http://github.com/IntelPython/mkl-service
  from . import _distributor_init
Traceback (most recent call last):
  File "C:\Users\tashi\.conda\envs\test1\lib\site-packages\numpy\core\__init__.py", line 24, in <module>
    from . import multiarray
  File "C:\Users\tashi\.conda\envs\test1\lib\site-packages\numpy\core\multiarray.py", line 10, in <module>
    from . import overrides
  File "C:\Users\tashi\.conda\envs\test1\lib\site-packages\numpy\core\overrides.py", line 8, in <module>
    from numpy.core._multiarray_umath import (
ImportError: DLL load failed while importing _multiarray_umath: 找不到指定的模块。

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\tashi\.conda\envs\test1\lib\site-packages\numpy\__init__.py", line 130, in <module>
    from numpy.__config__ import show as show_config
  File "C:\Users\tashi\.conda\envs\test1\lib\site-packages\numpy\__config__.py", line 4, in <module>
    from numpy.core._multiarray_umath import (
  File "C:\Users\tashi\.conda\envs\test1\lib\site-packages\numpy\core\__init__.py", line 50, in <module>
    raise ImportError(msg)
ImportError: 

IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!

Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.

We have compiled some common reasons and troubleshooting tips at:

    https://numpy.org/devdocs/user/troubleshooting-importerror.html

Please note and check the following:

  * The Python version is: Python3.9 from "C:\Users\tashi\.conda\envs\test1\python.exe"
  * The NumPy version is: "1.26.4"

and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.

Original error was: DLL load failed while importing _multiarray_umath: 找不到指定的模块。


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "D:\project\python\transformer\main.py", line 5, in <module>
    import torch
  File "C:\Users\tashi\.conda\envs\test1\lib\site-packages\torch\__init__.py", line 1215, in <module>
    from .storage import _StorageBase, TypedStorage, _LegacyStorage, UntypedStorage, _warn_typed_storage_removal
  File "C:\Users\tashi\.conda\envs\test1\lib\site-packages\torch\storage.py", line 14, in <module>
    import numpy as np
  File "C:\Users\tashi\.conda\envs\test1\lib\site-packages\numpy\__init__.py", line 135, in <module>
    raise ImportError(msg) from e
ImportError: Error importing numpy: you should not try to import numpy from
        its source directory; please exit the numpy source tree, and relaunch
        your python interpreter from there.

Process finished with exit code 1

定位发现,是因为新创建的虚拟python环境的路径(C:\Users\tashi\.conda\envs\test1\Library\bin)没有加到pycharm环境变量中。

解决方法:
点击Edit Configurations->Environment variables->文件图标->输入conda配置的Python环境路径C:\Users\tashi\.conda\envs\test1\Library\bin

解决后再运行不再报错,效果如下:

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/616503.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

供应链复杂业务实时数仓建设之路

供应链复杂业务实时数仓建设之路 背景 供应链业务是纷繁复杂的&#xff0c;我们既有 JIT 的现货模式中间夹着这大量的仓库作业环节&#xff0c;又有到仓的寄售&#xff0c;品牌业务&#xff0c;有非常复杂的逆向链路。在这么复杂的业务背后&#xff0c;我们需要精细化关注人货…

Redis搭建主从

Redis搭建主从: 1:拉取Redis镜像 docker pull redis2:创建主从对应的目录结构 3:对redis6379.log,redis6380.log,redis6381.log进行授权 chmod 777 redis6379.log chmod 777 redis6380.log chmod 777 redis6381.log4:修改主(master)的配置文件 5:创建主(master) redis_6379 …

express服务器 authorization 前端获取不到的问题

服务器生成token 设置在响应头&#xff0c;但是前端获取不到 const token JWT.generate({ id: new Date().getTime(), userName }, 10s) res.header(Authorization, token) axios.interceptors.response.use((response) > {console.log(response);if (response.data?.co…

【opencv】示例-neural_network.cpp 使用机器学习模块创建并训练一个简单的多层感知机(神经网络)模型...

#include <opencv2/ml/ml.hpp> // 引入OpenCV的机器学习模块using namespace std; // 使用标准命名空间 using namespace cv; // 使用OpenCV命名空间 using namespace cv::ml; // 使用OpenCV机器学习命名空间int main() {//创建随机训练数据Mat_<float> data(100, …

Linux的内存管理子系统

大家好&#xff0c;今天给大家介绍Linux的内存管理子系统&#xff0c;文章末尾附有分享大家一个资料包&#xff0c;差不多150多G。里面学习内容、面经、项目都比较新也比较全&#xff01;可进群免费领取。 Linux的内存管理子系统是Linux内核中一个非常重要且复杂的子系统&#…

文件IO/标准IO

1.标准I/O 标准&#xff1a; 任何操作系统皆可使用&#xff1b;使用范围很广 系统调用和库函数 系统调用&#xff1a;操作系统给我们提供的接口 man 2 printf 可以调用内核中的接口 直接驱动显卡运行 printf实际是库函数中的函数&#xff0c;然后调用系…

openkylin系统通过网线连接ubuntukylin系统上网攻略

openkylin系统通过网线连接ubuntukylin系统上网攻略 主机1&#xff1a;x64 amd &#xff0c;系统&#xff1a;ubuntukylin 22.04 &#xff0c;状态&#xff1a;通过wifi连接热点进行上网&#xff0c;并共享网络。 主机2&#xff1a;x64 intel &#xff0c;系统&#xff1a;ope…

字体体积压缩

环境:python3 关键步骤: pip install fontTools目录详情: 执行 pyftsubset.exe SourceHanSansCN-Medium.ttf --text-file3500.txt然后打开:TTF To Woff2,选择文件上传,等待处理,下载,使用 附常用汉字,字体文件请善用百度 3500.txt 工才下寸丈大与万上小口山巾千乞川亿个…

Redis队列与Stream

Redis队列与Stream、Redis 6多线程详解 Redis队列与StreamStream总述常用操作命令生产端消费端单消费者消费组消息消费 Redis队列几种实现的总结基于List的 LPUSHBRPOP 的实现基于Sorted-Set的实现PUB/SUB&#xff0c;订阅/发布模式基于Stream类型的实现与Java的集成消息队列问…

thinkphp6入门(23)-- 如何导入excel

1. 安装phpexcel composer require phpoffice/phpexcel composer update 2. 前端 <form class"forms-sample" action"../../xxxx/xxxx/do_import_users" method"post" enctype"multipart/form-data"><div class"cont…

cron表达式使用手册

cron表达式 我们在使用定时调度任务的时候&#xff0c;最常用的就是cron表达式。通过cron表达式来指定任务在某个时间点或者周期性执行。 范围&#xff1a; 秒&#xff08;0-59&#xff09;&#xff08;可选&#xff09; 分&#xff08;0-59&#xff09; 时&#xff08;0-…

如何对图像进行聚类

文章来源&#xff1a;https://medium.com/voxel51/how-to-cluster-images-6e09bdff7361 2024 年 4 月 10 日 使用 FiftyOne、Scikit-learn和特征嵌入 在 2024 年深度学习的计算密集型环境中&#xff0c;集群一词最常出现在讨论 GPU 集群时--高度优化的矩阵乘法机器的大规模集…