How do I configure Python and organise my interpreters?

岁酱吖の 提交于 2020-06-13 09:32:11

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/61913284/how-do-i-configure-python-and-organise-my-interpreters

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!