Home > OS >  Mac Terminal ttys000 back to Console (base)
Mac Terminal ttys000 back to Console (base)

Time:01-11

I am a novice coder and I am currently learning python and the Mac terminal.

Main Question: How do I return back to the original state of the Mac Terminal where it says Console and (base)? My mac terminal is currently on ttys000. (Both are -bash)

Originally when opening the Mac Terminal, I was presented with this:

Last login: Sat Jan  5 13:30:29 on console

The default interactive shell is now zsh.
To update your account to use zsh, please run `chsh -s /bin/zsh`.
For more details, please visit https://support.apple.com/kb/HT208050.
(base) Myusernamehere-MacBook-Pro:~ Myusernamehere$ 

However, currently, when opening the Mac Terminal, I am presented with this:

Last login: Sat Jan  8 19:18:51 on ttys000

The default interactive shell is now zsh.
To update your account to use zsh, please run `chsh -s /bin/zsh`.
For more details, please visit https://support.apple.com/kb/HT208050.
Myusernamehere-MacBook-Pro:~ Myusernamehere$ 

Why is this occurring?: I was attempting to make my python code become an application via py2app. This did not work so I tried converting the python script into a DMG file. Here are some of the tutorials I attempted to follow:

Why I am looking to get this fixed?: When the Mac terminal was in its original state with Console and (base), it recognized my pip imports for PIL, mplfinance, pandas_datareader, and yahoo_fin. Now when the mac is on ttys000, PIL, mplfinance, pandas_datareader, and yahoo_fin are no longer recognized as module names. In the mac terminal, after attempting to run the program (the name of my vscode python script is called V1_terminal, I am presented with this:

Myusernamehere-MacBook-Pro:Stock_Market Myusernamehere$ python V1_terminal.py
Traceback (most recent call last):
  File "V1_terminal.py", line 4, in <module>
    from PIL import ImageTk, Image
ImportError: No module named PIL

My program is stored in vscode with python 3.8.8 64-bit ('base': conda) Thus, I am unable to run the code.

In vscode, in python, this is my import lines of code:

#imports for GUI
import tkinter as tk 
from tkinter import *
from PIL import ImageTk, Image
import os
from numpy import loads, place

# for Yahoo Finance 
from yahoo_fin.stock_info import *
import yahoo_fin.stock_info as yaf
import mplfinance as mpf

# for data series and plot
from pandas_datareader import data 
from datetime import datetime, timedelta
import pandas as pd
import numpy as np
import requests
import matplotlib.pyplot as plt

Thank you so much in advance for offering advice and helping me! If I should add more context please let me know. Thank you!

Updates:

I tried conda activate in the terminal window and this is the result:

Last login: Mon Jan 10 13:13:22 on ttys000

The default interactive shell is now zsh.
To update your account to use zsh, please run `chsh -s /bin/zsh`.
For more details, please visit https://support.apple.com/kb/HT208050.
Myusernamehere-MacBook-Pro:~ Myusernamehere$ conda activate
-bash: /opt/anaconda3/bin/conda: /opt/anaconda3/bin/python: bad interpreter: No such file or directory
Myusernamehere-MacBook-Pro:~ Myusernamehere$ 

I tried conda config --set auto_activate_base true and this is the result:

Last login: Mon Jan 10 16:11:40 on ttys000

The default interactive shell is now zsh.
To update your account to use zsh, please run `chsh -s /bin/zsh`.
For more details, please visit https://support.apple.com/kb/HT208050.
Myusernamehere-MacBook-Pro:~ Myusernamehere$ conda config --set auto_activate_base true
-bash: /opt/anaconda3/bin/conda: /opt/anaconda3/bin/python: bad interpreter: No such file or directory
Myusernamehere-MacBook-Pro:~ Myusernamehere$ 

CodePudding user response:

So what I ended up doing is deleting Anaconda-Navigator from my Macbook then attempted to redownload it but ran into the error:

Anaconda3 is already installed in /opt/anaconda3. Use 'conda update anaconda3' to update Anaconda3.

So I used the answer found in this StackOverflow post and punched it into the Mac Terminal and successfully redownloaded the Anaconda-Navigator:

Anaconda-Navigator Error

I reinstalled mplfinance, yahoo_fin, etc via pip in the Mac Terminal and my python code successfully runs! The Terminal is still on ttys000 (and not Console like originally) but I am successfully running code. Feels like a rudimentary way to solve this but seems like everything is okay now. Thank you to you all for your time helping me!

CodePudding user response:

here is what you can do:

  1. Setup a virtual env
python3 -m venv venv
source venv/bin/activate
  1. pip install tk numpy yahoo_fin mplfinance pandas pandas_datareader requests matplotlib

  2. Optionally save the requirements into a file.. "pip freeze > requirements.txt" and check it in with your code. Next time you can do "pip install -r requirements.txt"

Now run your program.

Setting up a venv is a one time thing.. next time you open a new terminal, just activate the venv

source venv/bin/activate

you now are inside an environment which has your packages installed..

  •  Tags:  
  • Related