如何配置Python并组织我的解释器? [英] How do I configure Python and organise my interpreters?

查看:100
本文介绍了如何配置Python并组织我的解释器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

背景:

我已经在MacOS上学习Python大约三个月了,所以请放轻松.我首先通过Anaconda安装Python 3.7,主要使用Jupyter Notebook编写代码.随着我学到更多,我发现了不同的文本编辑器和IDE,并尝试了不同的程序:IDLE,Sublime和PyCharm.

随着我的进步,我还了解了包装管理系统,例如pip和conda,以及其他一些奇妙的东西,这些东西帮助我实现了自己想要的东西.

问题:

在我安装PyCharm和Python 3.9之后出现了问题.

我的计算机现在安装了四个或五个不同版本的Python(2.7、3.7、3.8、3.9)-我似乎已多次下载了其中一些版本-现在什么都行不通了!我使用pip安装的模块无法正常加载,我的精美程序(其中一些程序长度超过600行)不再运行-我什至无法运行简单的print('hello world').

我的文件一团糟.我可能有超过500mb的我不使用的与Python相关的垃圾.我已经篡改了控制台中的PATH和bin,甚至不知道如何开始进行整理.

我想要的/您将如何帮助我

对我来说,理想的解决方案是仅安装PyCharm和Jupyter Notebook,并使它们都能够导入我已安装的模块.我还想删除旧版本的Python,只是让Jupyter Notebook和PyCharm都使用3.9作为它们的解释器.此外,我想安全删除过去几个月中收集到的所有垃圾文件,尽管我知道您可能无法为此提供帮助.

简而言之:我只希望一切重新开始!

我花了数周的时间编写了一个基本上已经完成的程序,现在甚至没有使它通过第二行而没有抛出错误.

您有什么建议/潜在的解决方案吗?我乐于接受任何东西,包括备份文件和重置整个mac(尽管我想将其保留为计划C).

如果我在问题中说错了任何地方,请纠正我-我仍在与行话打交道,感觉好像在寻求我无法正确表达的问题的帮助-请写信尽可能简单地解决您的问题,向您解释您觉得初学者可能不理解的所有内容.

先谢谢了.

解决方案

我已经解决了自己的问题,但进行了大量调查,并概述了我所做的事情:

  1. 重置Mac(这不是必需的,但我还是想这样做)
  2. 安装自制软件
  3. 安装pyenv
  4. 安装pipenv

对于遇到相同问题的任何人,您绝对应该研究pyenv和pipenv,作为管理Python版本和模块的一种方式.

我不会像其他许多文章一样详细介绍细节,但是会发布一些对我有帮助的好文章的链接:

https://opensource.com/article/19/5/python-3-default-mac

https://realpython.com/intro-to-pyenv/

https://pipenv-fork.readthedocs.io/en/latest/

希望这会有所帮助.

Background:

I have been learning Python (on MacOS) for about three months now, so please go easy on me. I began by installing Python 3.7 through Anaconda and predominantly used Jupyter Notebook to write code. As I learnt more, I found out about different text editors and IDEs, and tried out different programs: IDLE, Sublime and PyCharm.

As I progressed I also learned about package management systems, such as pip and conda, and other such wonderful things that helped me achieve the things I wanted.

The Problem:

Problems surfaced after I installed PyCharm and Python 3.9.

My computer now has four or five different versions of Python installed (2.7, 3.7, 3.8, 3.9) - some which I seem to have downloaded multiple times - and now nothing works anymore! The modules I have installed using pip don't load properly anymore, my gorgeous programs (some of which are over 600 lines long) don't run anymore - I can't even run a simple print('hello world') anymore.

My files are a mess. I have probably over a 500mb of Python related junk that I don't use. I have tampered with PATHs and bins in the console, and I don't even know how to begin to sorting this out.

What I Want / How You Can Help Me:

An ideal solution for me would be to just have PyCharm and Jupyter Notebook installed and for them to both be able to import the modules I have installed. I would also like to remove older versions of Python and just have both Jupyter Notebook and PyCharm use 3.9 as their interpreter. Additionally, I would like to safely delete all the junk files that I have collected over the last few months, though I understand that you might not be able to help me with that.

In short: I just want everything to work again!

I spent weeks writing a program that was basically finished and now doesn't even make it passed the second line without throwing out an error.

Do you have any advice / potential solutions? I am open to anything, including backing up my files and reseting my whole mac (though I'd like to reserve this as plan C).

Please, correct me if I have said anything wrong in my question - I am still getting to grips with the lingo, and I feel as if I am asking for help on a problem I can't express properly - and please write your solution as plainly as possible, explaining anything you feel a beginner may not understand.

Thanks in advance.

解决方案

I have solved my own problem but it took quite a bit of investigation, and will outline what I did:

  1. Reset my Mac (this was not necessary but I wanted to do it anyway)
  2. Install home-brew
  3. Install pyenv
  4. Install pipenv

For anyone experiencing the same problems, you should look definitely into pyenv and pipenv as a way of managing your Python versions and modules.

I won't go into too much detail, as plenty of other already have, but will post some links to some good articles that helped me:

https://opensource.com/article/19/5/python-3-default-mac

https://realpython.com/intro-to-pyenv/

https://pipenv-fork.readthedocs.io/en/latest/

Hope this helps.

这篇关于如何配置Python并组织我的解释器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆