简体   繁体   中英

zsh: commands not working for pip, conda, python

So here is my story: As we know macos comes with pyhton 2.7 preinstalled. Years ago, I installed python 3.7.0 and all going good. I started working with Tensorflow and during that time tensorflow wasn't compatible with 3.7.0 so switch the version to 3.6.6 somehow:). After some time i installed anaconda and it installed 3.7.3. At this point:

  • When i open my python IDLE shell, it runs on 3.6.6
  • anaconda Jupiter notebook shows 3.7.3.

Then i learned to create virtual environments through terminal and i use following code to create virtual environment:

pip install virtualenv
virtualenv project_env

And after i activate the virtual environment the python version it shows is 3.7.3.


Then recently i changed the terminal shell to zsh and now everything is kind of messed up. I'm

  1. Terminal can't find conda commands. How to fix that?
  2. Now i can't create virtual environment through virtualenv project_env . It says command not found. Why? It use to create virtual environments with python 3.7.3 .
  3. Now to create virtual environment i use python3 -m venv project_env this creates the virtual environment with python 3.6.6 . If i use python3.7 -m venv project_env it creates environment with python 3.7.0 .
  4. I can't find a way to create virtual environments with python 3.7.3 .

I need help with above troubles caused after installing zsh and help with accessing python versions wherever i need. How do i update python version 3.7.0 to latest or any specific version like 3.7.3. Hows python 3.8.4 to use, i mean like i had trouble importing tensorflow in python 3.7.0.

I hope you will understand my trouble and searched a lot for solutions. I'm so confused right now, couldn't even figure out the title of my problem.

Based on the fact your shell can't find conda now, you should look at your "path" environment variable. Whenever you change from one shell to another, you need to look at and possible create or modify the files the shell uses upon startup. These files setup your environment (PATH, PYTHONPATH, etc), create aliases, etc. You may need to create the.zshrc, .zprofile, .zlogin etc files and add the same settings as your previous shell's startup files.

Example: If you used the bash shell previously you would need to modify the.zshrc file to include your settings in the.bashrc file. Syntax may be different, so a straight copy may or may not work.

Try this as a quick temporary fix (may or may not work, depending on your current ~/.profile settings:

Create a ~/.zprofile file with this code inside:

emulate sh
. ~/.profile
emulate zsh

references: https://superuser.com/questions/187639/zsh-not-hitting-profile http://zsh.sourceforge.net/Intro/intro_3.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM