如何在服务器下基于Anaconda运行Pycharm上的程序?

1. 如何打开服务器

首先在服务器上新建账户和密码

之后打开cmd,输入mstsc,再输入地址,我的是:10.106.13.92,输入账户和密码

2. 如何把Windows下文件移到服务器上?

首先在服务器上修改账户权限(允许使用scp从windows向服务器传程序)

在windows当前路径下输入:

scp -r ... your fold name ysc@10.106.13.92:/mnt/Data0/ysc_projects/

并输入密码,即可开始传输文件夹

注意:路径中不能有中文!

3. 如何在服务器上运行程序?

在服务器上Pycharm的Python Interpreter是没有Python 3.8和Anaconda 3.8的,需要自行下载安装,Anaconda下载地址,下载Linux Python 3.8
64-Bit (x86) Installer (529 MB),在/home/... your name/Downloads/下会有名为Anaconda3-202.11-Linux-x86_64.sh的文件

输入:

bash Anaconda3-202.11-Linux-x86_64.sh

在这里插入图片描述
重启一遍远程连接,输入以下命令:

(base) ysc@aaa-pc:~/Desktop$ conda activate
(base) ysc@aaa-pc:~/Desktop$ python -V
Python 3.8.5

可以发现Anaconda已经配置好了

下面进行换源:

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --set show_channel_urls yes
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/menpo/

输入以下代码查看源:

conda config --show-sources

在这里插入图片描述

安装torch

参考之前的Blog,pycharm鼠标滚轮缩放参考此文,最终配置完成:

import torch

print(torch.cuda.is_available())

print(torch.__version__)
print(torch.version.cuda)
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
print(device)
True
1.8.0
10.2
cuda

安装pyqt5

参考之前的Blog,安装后报错:

ERROR: After October 2020 you may experience errors when installing or updating packages. This is because pip will change the way that it resolves dependency conflicts.

We recommend you use --use-feature=2020-resolver to test your packages with the new resolver before it becomes the default.

spyder 4.1.5 requires pyqtwebengine<5.13; python_version >= "3", which is not installed.
spyder 4.1.5 requires pyqt5<5.13; python_version >= "3", but you'll have pyqt5 5.15.4 which is incompatible.

暂时忽视,安装jieba分词:

conda install jieba

运行程序报错:

ImportError: /usr/lib/x86_64-linux-gnu/libgssapi_krb5.so.2: symbol krb5_ser_context_init version krb5_3_MIT not defined in file libkrb5.so.3 with link time reference

看看原来的版本:

from PyQt5.QtCore import QT_VERSION_STR
from PyQt5.Qt import PYQT_VERSION_STR
print("Qt5 Version Number is: {0}".format(QT_VERSION_STR))
print("PyQt5 Version is: {}".format(PYQT_VERSION_STR))
Qt5 Version Number is: 5.15.2
PyQt5 Version is: 5.15.4

Linux下利用conda安装pyqt5:

conda install pyqt=5.15.4

找不到此文件,输入:

conda search pyqt

发现最高只有5.12.3版本的pyqt5,更新一下conda试试:

conda update conda

依然最高只有5.12.3版本,先利用pip下载此版本,之后报错:

ERROR: After October 2020 you may experience errors when installing or updating packages. This is because pip will change the way that it resolves dependency conflicts.

We recommend you use --use-feature=2020-resolver to test your packages with the new resolver before it becomes the default.

spyder 4.1.5 requires pyqtwebengine<5.13; python_version >= "3", which is not installed.
pyqt5-plugins 5.15.2.2.0.1 requires pyqt5==5.15.2, but you'll have pyqt5 5.12.3 which is incompatible.

利用conda -V查看版本号,Windows上conda版本为4.9.2,服务器也是4.9.2,怎么下载5.15.4的Pyqt5呢?

问题:
5.14以上的Pyqt5有pyqt5-plugins,但是5.14以下的Pyqt5运行才不会报错…暂无解决办法

评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值