当前位置: 首页 > article >正文

Linux搭建conda虚拟环境流程

文章目录

      • Requirements
      • 搭建虚拟环境
        • 方法 1:使用 `--prefix` 参数删除指定路径的虚拟环境
        • 方法 2:手动删除指定路径的虚拟环境
      • requirements.txt
      • 实验室电脑装环境一些问题:
        • `numpy`包问题:
          • 1. **确保环境干净并重新安装 `numpy`**(可解决)
          • 2. **使用 Conda 安装 `numpy`(推荐)**
        • `scipy`包问题:
          • 1. **重新安装 `scipy`**(可解决)
          • 2. **使用 `conda` 安装 `scipy`(推荐)**

Requirements

  • Python == 3.7 or 3.8
  • tensorflow == 2.X (verified working with 2.0 - 2.3, both for CPU and GPU)

To run the EEG/MEG ERP classification sample script, you will also need

  • mne >= 0.17.1
  • PyRiemann >= 0.2.5
  • scikit-learn >= 0.20.1
  • matplotlib >= 2.2.3

搭建虚拟环境

先查看conda的基本设置cofig:

conda config --show

使用conda创建虚拟环境:

conda create --prefix D:\Anaconda\envs\EEG python=3.7

查看虚拟环境是否创建成功:

conda env list

激活虚拟环境:

conda activate EEG

使用conda安装TensorFlow2.3.0版本:

pip install tensorflow==2.3.0

手动安装与TensorFlow2.3.0相兼容的包:

pip install mne==1.3.1 pyriemann==0.2.5 scikit-learn==0.22.2 matplotlib==3.5.3 seaborn==0.11.0

查看各个包的版本是否兼容(cmd中无warning):

pip list

注:

如果TensorFlow需重装(其他包一样):

pip uninstall tensorflow
pip install tensorflow==2.3.0

删除envs环境:

要删除位于指定路径的 conda 虚拟环境,你可以按照以下步骤操作:

方法 1:使用 --prefix 参数删除指定路径的虚拟环境

conda 提供了 --prefix 参数,可以直接指定虚拟环境的完整路径来删除它。具体步骤如下:

  1. 使用命令删除环境
    可以使用 conda env remove --prefix envs_path 来删除它。

    conda env remove --prefix D:\Anaconda\envs\EEG
    
  2. 验证删除成功
    删除成功后,运行以下命令来检查环境是否还存在:

    conda env list
    
方法 2:手动删除指定路径的虚拟环境
  1. 手动删除文件夹:直接删除该路径下的虚拟环境文件夹。

  2. 更新 conda 的环境列表
    conda 可能仍然记录着环境的存在。使用以下命令清除无用的环境和缓存文件:

    conda clean --all
    

requirements.txt

tensorflow==2.3.0
pyriemann==0.2.5 
scikit-learn==0.22.2 
matplotlib==3.5.3 
seaborn==0.11.0
mne==1.3.1(非必须,看数据集)

实验室电脑装环境一些问题:

numpy包问题:
ImportError: Unable to import required dependencies:
numpy: 

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.7 from "C:\Users\lenovo\.conda\envs\python3.7\python.exe"
  * The NumPy version is: "1.21.6"

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: 找不到指定的模块。
1. 确保环境干净并重新安装 numpy(可解决)

卸载后重新安装 numpy,可能会解决一些依赖问题:

pip uninstall numpy
pip install numpy
2. 使用 Conda 安装 numpy(推荐)

如果你在使用 conda 环境,可以尝试通过 conda 重新安装 numpy,因为它会处理依赖关系:

conda install numpy
scipy包问题:
C:\Users\lenovo\.conda\envs\python3.7\python.exe C:\Users\lenovo\Desktop\Project\pre_data\neu_data_extract.py 
Traceback (most recent call last):
  File "C:\Users\lenovo\Desktop\Project\pre_data\neu_data_extract.py", line 1, in <module>
    import scipy.io as sio
  File "C:\Users\lenovo\.conda\envs\python3.7\lib\site-packages\scipy\__init__.py", line 136, in <module>
    from . import _distributor_init
  File "C:\Users\lenovo\.conda\envs\python3.7\lib\site-packages\scipy\_distributor_init.py", line 59, in <module>
    WinDLL(os.path.abspath(filename))
  File "C:\Users\lenovo\.conda\envs\python3.7\lib\ctypes\__init__.py", line 364, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] 找不到指定的模块。

进程已结束,退出代码为 1

1. 重新安装 scipy(可解决)

卸载并重新安装 scipy,可能会解决依赖问题。

pip uninstall scipy
pip install scipy
2. 使用 conda 安装 scipy(推荐)

如果你在使用 conda 环境,建议用 conda 安装 scipy,它会自动解决依赖问题。

conda install scipy

如何切换pip的源:详细指南(网络问题,conda清华源速度也不行,so使用pip清华源,下载速度可以)
如果你在使用 conda 环境,建议用 conda 安装 scipy,它会自动解决依赖问题。

conda install scipy

如何切换pip的源:详细指南(网络问题,conda清华源速度也不行,so使用pip清华源,下载速度可以)


http://www.kler.cn/a/589124.html

相关文章:

  • never_give_up
  • 聊一下CSS层叠
  • Centos离线安装perl
  • redis zset基本介绍以及底层实现
  • 【网络】Caddy 服务器如何提供 TLS(Transport Layer Security)(传输层安全协议)
  • 短视频下载去水印,用什么工具好?
  • 使用 Chrome Flags 设置(适用于 HTTP 站点开发)
  • Spring WebSocket 像写http接口一样处理WebSocket消息(Stomp协议)
  • iOS底层原理系列02-深入了解Objective-C
  • LInux基础--apache部署网站
  • rust 的Clone
  • 基于SpringBoot的“考研互助平台”的设计与实现(源码+数据库+文档+PPT)
  • 深度学习中的向量的样子-DCN
  • Leetcode hot 100 191.对称二叉树
  • 2025站群泛目录程序秒收优化新策略(关键词布局与流量分配)
  • 鸿蒙模拟器运行NDK项目失败 9568347
  • 麒麟服务器操作系统Redis部署手册
  • Javaweb后端全局异常处理器
  • Elasticsearch-07-Elasticsearch Java API Client-Elasticsearch 8.0 的高阶api
  • C#的委托Action