Python -PythonIDE - PyCharm下载安装配置及 GitHub代码仓托管 排错记录

一、安装PyCharm开发环境

PyCharm 作为一款针对 Python 的编辑器,配置简单、功能强大、使用起来省时省心,对初学者友好,这也是为什么编程教室一直推荐新手使用 Pycharm 的原因。下载安装 (PyCharm官方网站下载Community社区免费版。

错误: 安装后新建项目时提示错误 “interpreter field is empty“ 如图所示。
原因: 没安装这个python解释器。
解决办法: Python官网(https://www.python.org/)下载把适合版本的python下好安装就没问题了。

二、新建项目

新建Python项目流程请 参考这篇文章

在这里插入图片描述
Pycharm界面:
在这里插入图片描述

三、配置 Pycharm

1、基本配置

  • 显示行号。依次点击 【File】-【Settings】-【Editor】-【General】-【Appearance】右边勾选 Show line numbers
    在这里插入图片描述
  • 黑白背景设置。依次点击【File】-【Settings】-【Appearance】-【Theme】后,Darcula为黑色背景。
    在这里插入图片描述

2、选择/更换 解释器

路径 :rs\Users\AppData\Local\Programs\Python\Python39\python.exe
在这里插入图片描述

3、添加模块

  • 1、中端Terminal 输入以下命令:
    python.exe -m pip install 模块名称 -i http://pypi.douban.com/simple --trusted-host pypi.douban.com
  • 2、依次点击【File】-【Settings】后,点击 “+”号,搜索库名添加即可。>>参考文章<<
    在这里插入图片描述
  • 3、利用Python内置的pip工具(安装Python3.8时会自动安装该工具)可以非常方便地安装Python第三方模块,该工具可在命令行中使用,语法格式如下:
    • pip install 模块名 注意: pip是 在线工具,pip命令执行后,它需要联网获取模块资源,若没有网络或网络不佳,pip将无法顺利安装第三方模块。

4、更改文件名

选中需要重命名的文件,点击右键,选择【Refector】重构,选择子菜单中的【Rename】完成重命名,完整操作演示如下:

在这里插入图片描述

四、PyCharm 代码同步GitHub
问题一:PyCharm中使用 GitHub 账号登录 报错:invalid authentication data 404 not found

在这里插入图片描述
解决方法:首先登录GitHub设置new token后,回到PyCharmuse 使用令牌(use token)登录就行了。
大致操作:首先登陆GitHub,找到Set tings—>Develop Settings—>Personal access tokens (个人访问令牌) >>参考办法<<
在这里插入图片描述

问题二:PyCharm 中测试Git 报错: ”Cannot Run Git “解决方法

原因:没有安装Git
解决:下载安装Git后,在下面页面中配置安装路径,点击Test 测试 即可。
在这里插入图片描述
至此所有的环境就设置完成了,依次点击上面菜单栏中的VCS–>Import into Version Control --> Share Project on Github,把这个项目上传到GitHub。

问题三:422 Unprocessable Entity - Repository creation failed.

报错:Failed to create GitHub Repository
422 Unprocessable Entity - Repository creation failed.
[Repository;description]custom:description control characters are not allowed
在这里插入图片描述
在这里插入图片描述
原因:是因为Description 描述里面有中文,不符合要求。
在这里插入图片描述
按照之前的操作重新上传一次后,会弹出一个新的对话框,会让选择要上传的文件以及填写提交信息等。当然一般情况下都是按照默认的就可以了。设置完成后,点击Add按钮。
在这里插入图片描述
大功告成!!!
在这里插入图片描述

问题 四(2021.9.24):创建仓库后,提交上传文件报错:Successfully created project ‘Chapter3’ on GitHub, but initial commit failed……

报错 1.:Successfully created project 'Chapter3' on GitHub, but initial push failed: Warning: Permanently added 'github.com' (RSA) to the list of known hosts. git@github.com: Permission denied (publickey). Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.
翻译:已在 GitHub 上成功创建项目“Chapter3”,但初始推送失败:警告:已将“github.com”(RSA) 永久添加到已知主机列表中。 git@github.com:权限被拒绝(公钥)。无法从远程存储库读取。请确保您拥有正确的访问权限并且存储库存在。

报错2:Can't finish GitHub sharing process
Successfully created project 'Chapter3' on GitHub, but initial commit failed:
*** Please tell me who you are. Run git config --global user.email "you@example.com" git config --global user.name "Your Name" to set your account's default identity. Omit --global to set the identity only in this repository. fatal:
empty ident name (for (null)>) not allowed during executing git -c core.quotepath=false commit -m "Initial commit" --

原因:Run git config --global user.email “you@example.com” git config --global user.name " 原来是github没有配置的原因。

解决办法: >>参考方法1<< 、>>参考方法2<<

  • 1.在你安装 Git 的目录下找到git-bash这个可执行文件
  • 2.设置用户名邮箱地址,如下:

$ git config --global user.name "your name
$ git config --global user.email “your_email@youremail.com”

在这里插入图片描述
在这里插入图片描述

问题五 (2021.10.10):PUSH失败,权限被拒绝

报错信息:9:15 Push failed
Git@github.com: Permission denied (publickey).
Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.

原因:9:15 推送失败,权限被拒绝(公钥)。无法从远程存储库读取。请确保您拥有正确的访问权限
并且存储库存在。大概率秘钥设置不对的问题

解决方法:>>参考文章<<

解决步骤如下

在GitHub的https://github.com/settings/keys上添加你本机的 SSH key

1、打开Shell(Windows下打开 Git Bash , 在安装GIT 的路径文件中),创建SSH Key

命令:$ ssh-keygen -t rsa -C "youremail@example.com"

把邮件地址换成你自己的邮件地址,然后一路回车,使用默认值即可。
在这里插入图片描述
2、如果一切顺利的话,可以在用户主目录里找到.ssh目录,里面有id_rsa和id_rsa.pub两个文件,这两个就是SSH Key的秘钥对,id_rsa是私钥,不能泄露出去,id_rsa.pub是公钥,可以放心地告诉任何人。

在这里插入图片描述

3、登陆 GitHub,打开Account settingsSSH Keys页面:

在这里插入图片描述

然后,点Add SSH Key,填上任意 Title,在Key文本框里粘贴 id_rsa.pub文件内的内容。

Add Key,你就应该看到已经添加的 Key。

这样应该就可以正常 push了。

在这里插入图片描述


五、PyCharm 快捷键
  • 批量注释:选择要注释的文本行, 背景变化后,同时按Ctrl+/
  • 取消批量注释:选择要注释的文本行, 背景变化后,同时按Ctrl+/
  • 批量缩进:选择要注释的文本行, 背景变化后,同时按TAB
  • 取消批量缩进:选择要缩进的文本行, 背景变化后,按下SHIFT+TAB
键 位说 明
Ctrl+/批量注释:选择要注释的文本行, 背景变化后,同时按Ctrl+/,取消批量注释:同上再操作一次。
TAB批量缩进:选择要注释的文本行, 背景变化后,同时按TAB
SHIFT+TAB取消批量缩进:选择要缩进的文本行, 背景变化后,按下SHIFT+TAB
Ctrl+Shift+F10运行代码
Shift+F9调试代码
双击Shift全局查找
Ctrl+Shift+S打开设置
shift + enter快速换行
#_*_ coding;uft-8 _*_

'''
PyCharm常用的「快捷键」:

1.shift + enter     :快速换行
2.ctrl + p          :代码提示
3.ctrl + alt +space :代码提示

PyCharm界面颜色设置 : File | Settings | Appearance & Behavior | Appearance|Darcula(暗色)
'''



Python控制台

参考资料:

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Naiva

你的鼓励将是我创作的最大动力!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值