I've been using anaconda for a while now and using the conda command relatively frequently. Recently I had to try installing miniconda for a new project. I ended up trying to delete the directory and reinstall it a new way following the tutorial from my school. I believe I used rm -rf /Users/MyUsername/software/pkg/miniconda3 . Now, anything I try to use the conda command for returns zsh: command not found: conda. Trying to open jupyter notebook returns zsh: command not found: jupyter Anaconda still exists on my computer inside /Users/MyUsername/opt/anaconda3 and conda terminal exists inside /Users/emilybaur/opt/anaconda3/condabin which I believe is the default location, so I'm confused why my terminal can't access it.
Anaconda Navigator still works and can open jupyter notebook, but nothing works through terminal. Could I have messed up the path being accessed by terminal somehow, or deleted a part of conda?
(Edited)
Related
I have just installed my Jupyter notebook to run Python . I have an active internet connection and python installed . I am getting an error saying "A connection to the notebook server could not be established. The notebook will continue trying to reconnect. Check your network connection or notebook server configuration."
The error is shown in the figure below
I tried running "conda info" on my terminal. This is what I got.
This is the output of my Jupyter notebook terminal
I tried reading many solutions on internet but it did not work .Can u please help me out?.
I think you may have too many variables affecting your install to be able to determine exactly what is wrong. I would recommend starting with a fresh install of Python use either 3.10.8 or 3.11.0:
https://www.python.org/ftp/python/3.10.8/python-3.10.8-amd64.exe
https://www.python.org/ftp/python/3.11.0/python-3.11.0-amd64.exe
Make sure you check the box for adding python.exe to PATH on the first step of the installer.
Check that the newly installed version is the correct one in your PATH:
c:\>python -V
If the version shown is different than the one you just installed, go look at your environemnt variables and make sure that your PATH is correct: the new install should be earlier in the PATH than other Python installs (or remove the others from PATH completely).
Then create an empty virtual environment from that Python install:
c:\>python -m venv c:\path\to\myenv
https://docs.python.org/3/library/venv.html#creating-virtual-environments
Then activate the fresh virtual environment:
C:\> c:\path\to\myenv\Scripts\activate.bat
Now install JupyterLab
pip install wheel jupyterlab
Finally, run JupyterLab:
jupyter lab
This should open the browser automagically. If you are still having problems, you have narrowed the number of variables because this is a clean basic install with nothing except for JupyterLab and nothing else. However, you may still have some configuration from a previous install. If you were working in that previous install and may have some valuable configuration settings, change the name of these directories to keep a copy of the old one to sort through on your own later: %PROGRAMDATA%\jupyter and %APPDATA%\jupyter. Or, if you have never gotten the previous install working at all, just delete these directories altogether. The next time you start Jupyter, they will be created fresh.
I need to use the command line in Jupyter Notebook in a virtual environment, but the commands don't execute in the environment itself. I'm using Anaconda Navigator to open Jupyter Notebook. For background, I use a Mac.
Whenever I do something like ! pip install xyz, it installs the package in the Anaconda directory for libraries (see the image). I made sure that the kernel is in the environment, so that's not the problem.
What's interesting is that if I try to import a package, I can only import packages from the environment itself, not the Anaconda libraries. In other words, installing packages doesn't occur in the environment, but importing packages does.
Image that shows the pip install
This wouldn't matter that much because I could download packages in the Terminal itself, but I also need to do things like in the image below in my virtual environment, which is not possible to do in the Terminal (or is it?).
Example of what I need to do
Any ideas on how to fix this?
EDIT: That error is fixed. However, I'm getting an error if I try to use a Python command: image of error. The first line just defines the file path for the script (the last item in the list is a .py file). I tried doing "%%python" followed by the command, but it doesn't work. Any ideas?
I've hit a dead end trying to solve/debug this issue which doesn't seem like it should be that difficult.
I'm working in Pycharm IDE (not the professional) and I'm working inside a virtual environment let's call it pythonProject and I want to be able to run launch a jupyter notebook in this environment so that it can pick up all the python packages i've installed and configured for this environment.
As I understand it from the documentation, these are the steps I need to take.
My terminal prompt statement:
(pythonProject) oliver#oliver-u20:~/pythonProject$
commands:
python3 -m pip install ipykernel
python3 -m pip install notebook
python3 -m ipykernel install --user --name pythonProject --display-name "Python (pythonProject)"
jupyter notebook
But when I load jupyter notebook, it only shows python3 under kernels.
I tried outputting
jupyter kernelspec list
And get only the base kernel which suggests from this that it's not finding my kernelspec, but I can't seem to figure from the documentation what i'm supposed to do.
Am I missing something?
Ok so I've solved this.
I think there was an install issue with jupyter.
I tried reproducing this in a completely new project and venv and could get the kernel showing.
In the project and venv where I still couldn't, I noticed a discrepancy in the output of my jupyter --paths
In the working venv I could see under data
/home/oliver/.local/share/jupyter
Which is where the kernels I installed are located.
However in the project that wasn't working there was instead:
/home/oliver/snap/jupyter/6/.local/share/jupyter
I'm guessing this snap path is from how I originally installed jupyter on my Ubuntu via the app store - seemed sensible at the time.
So I uninstalled jupyter, restarted my venv and the jupyter --paths has magically changed so that
/home/oliver/.local/share/jupyter
is present and when I start a jupyter notebook at the command line with
jupyter notebook
I can see all my kernels showing!
I found this quite difficult to debug with the documentation and command help outputs so hope someone else finds this useful.
I just updated my macOS to Catalina and I can't run python or open a jupyter notebook from terminal anymore. As an example, I get error message "ImportError: No module named pandas" when running my python code, and I get
zsh: command not found: jupyter
when running
jupyter notebook
This issue has brought me to anaconda (I would love someone to explain me why. Does python need anaconda to be ran?). I have tried several suggestions from https://github.com/ContinuumIO/anaconda-issues/issues/10998, e.g. I have tried copying folder "anaconda3" from "Relocated items" folder to "Users//", then
export PATH=''/Users/<username>/anaconda3/bin:$PATH"
but I get either
dquote>
or
zsh: /Users//Applications/anaconda3/bin/conda: bad interpreter: /anaconda3/bin/python: no such file or directory
I then tried to reinstall Anaconda using the graphic installer (from https://www.anaconda.com/distribution/#macos) following advice from someone from the anaconda team (https://www.anaconda.com/how-to-restore-anaconda-after-macos-catalina-update/) (I changed installation location to a folder I created in /Users//) but I still get the same error messages when running python3 or jupyter notebook.
How can successfully run python and jupyter notebook with macOS Catalina?
After installed macOS Catalina, we can switch the terminal from bash to zsh. There are many advantages from using zsh instead of bash, but One of the issues with zsh is some of the frameworks (jupyter notebook,conda) are not supported directly. Once I typed jupyter notebook in terminal to run it. It displayed “zsh: no such file or directory”.
The solver is simple but very difficult to find online.
If jupyter was already installed before the update and stopped working after zsh, you should be able to fix it by:
1.open zshrc in terminal by typing: open .zshrc or $open .zschrc
2. add the following line at the end of the file:
source ~/.bash_profile
It will ask zsh to use all the information from bash like the path of jupyter.
Hope it can help you out!
I'm answering to my own question in case it can help others ;)
I found my answer here: https://medium.com/#singhaniatanay18/mac-os-catalina-update-zsh-instead-of-bash-d688f68f70b8
(see comments as well)
Mac OS BigSur:
Uninstall Anaconda:rm -f Anaconda-Navigator.app
re-install pip3 install jupyterlab
I just updated to Catalina, two days before Big Sur release.. oh well.
Catalina came with changes to security and bash, that will remain for future releases. So Catalina moves your anaconda3 folder to /Users/Shared/Previously Relocated Items/Security/anaconda3 I tried to move it back to home directory, but that didn't work. So I deleted it, and reinstalled Anaconda using the command line installer Not the GUI installer, and it worked for me. You can follow instructions here and use /Users/me/anaconda3 folder as recommended here.
Here are the commands that worked for me,
shasum -a 256 /Users/username/anaconda3 . Although not sure it did anything
bash ~/Downloads/Anaconda3-2020.02-MacOSX-x86_64.sh or whatever the name of the command line installer from Conda in your Download folder, or wherever else you downloaded it.
Use sudo in front of the command if permission was denied, then enter your log in password for your Mac
source /Users/username/anaconda3/bin/activate conda init zsh
sudo conda init zsh then enter your Mac's password.
You should be all set now, and all commands like ipython, conda info, jupyter notebook, pyspark will all work.
The last command will make step3 command persist i.e. initialize conda base environment, such that you can run conda, ipython, jupyter notebook the next time you use terminal.
Install the Jupyter using Homebrew in zsh shell
If you don't Python install 3.3or higher.
Open terminal
Using Homewbrew install jupyter
brew install jupyter
Now, you start a notebook
jupyter notebook
I am new to programming and would appreciate help.
I had been running code successfully but recently installed conda, which is causing issues.
Sys.executable shows
C:\Users\Ben\AppData\Local\Programs\Python\Python37-32\pythonw.exe
in IDLE and
C:\Users\Ben\AppData\Local\Programs\Python\Python37-32\python.exe in
the command prompt.
However, when I run a script from my desktop calling sys.executable in the command prompt, it shows P:\conda\python.exe. When I run other scripts from files on my desktop it also can no longer import modules, which are stored in the same folder as my original Python installation.
My question is: how can I change the interpreter for the files I am running from my desktop so that they can find the correct modules?
I have read all of StackOverflow's ModuleNotFound and sys.executable related threads but cannot fully understand what is going on - thanks for the help.
create new python environment on conda as follows and run your code on new env:
Actually using conda and conda navigator is the better approach
After conda installation:
- Open up the conda command prompt and create your working environment as follwos
conda create -n mytestenv python=3.7
Activate the environment:
conda activate mytestenv
Now, Run your code.
Later on if you need any module, Install your module using conda command on your selected environment, for example
conda install numpy