Miniconda doesn't activate - python

I am working on a remote machine for my internship and ran into the following problem.
I ran conda install -c huggingface -c conda-forge datasets, which ended up taking ages (and for some reason downloaded a lot of useless packages) and seemingly got stuck, so I ctrl-c'ed the process. From there on, running source ./miniconda3/bin/activate would take upwards of 20 minutes. I tried deleting the entire folder ./miniconda3 and re-installing it from the shell file -- that didn't help.
I interact with conda using VSCode with Python and Jupyter Notebook extensions installed. I re-installed these extensions too out of despair, it also didn't fix the issue. I cannot run any cells in Jupyter, because activating the virtual environement times out. Is there something so that conda activation takes 1-2 seconds like it used to?

I'm not sure if this will fix it for you, but you could try making sure that you full uninstall miniconda before you re-install it. It makes changes to bashrc and has some other hidden folders. The vscode extension isn't going to be able to handle a 20 minute start up wait, so you'll need to resolve that issue first.
https://zditect.com/guide/python/uninstall-miniconda.html
Also I'm not sure that you should be calling source on the activation function of miniconda. At least for me, when using miniconda you should end up with conda on your terminal path. Then you just use conda activate to activate the environment you are working with.

Related

Issue connecting to the Kernel in Jupyter notebook

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 am not able to install pytorch in jupyter and Spyder?

I have tried installing pytorch on jupyter and spyder but it is not working. I have install it in conda env, from pytorch documentation tried everything.
From pytorch documentation and it shows pytorch installed 100%
In conda env. Installed for jupyter and spyder
In conda list pytorch is not showing
I have tried to open from app after installing in conda env. But it is Not opening here in jupyter, a pop up window appears each time for 1-2 seconds then disappears.
Is there any other way to install it ?? Please help
Your issue is simply that conda fails to install pytorch; this can have multiple causes. Forget about spyder and jupyter, they're not the issue.
1. From pytorch documentation and it shows pytorch installed 100%
No it doesn't. Look at the bottom line: Rolling back transaction: ...working... done. conda did not successfully install the package. You need to debug further why (permissions issue on directory? installing under userid? dependency conflict?) Follow my suggestions at bottom.
2. In conda env. Installed for jupyter and spyder
No they don't! They only show that conda has (previously) installed the jupyter and spyder executables. Those don't tell you which conda packages are installed. That's what conda list does.
3. In conda list pytorch is not showing
Correct. Because it never installed it in the first place, as per 1. above.
You must debug why step 1. fails. There are many possible causes and you haven't given enough debugging information that we can tell which.
Please post extra information on why it fails. Suggest you do the following:
Try just conda install pytorch -c pytorch by itself, not all the other packages, they make constraint solving harder.
Try verbose mode: conda install -v pytorch -c pytorch
verbose mode should show you why conda thinks it needs to roll back the transaction (e.g. conflicting dependencies for 2+ different packages)
Check which user and permissions you're doing conda install under, are they the same as the Anaconda install? (often if you use the GUI installer under Windows/Linux/Mac, it assumes it can/should as admin or else user, without asking you).
In rare cases, you might need to nuke your conda environment and create a new env. I'd do this if you can't debug it after say 48+ hours. If you install every package under 'base', in particular for R as well as Python, this is a known issue. Even if doesn't break things, using 'base' environment for too many things tends to slow down constraint solving to take many hours, or hang forever.
Finally, after you do finally get the package installed, see if you need to set PYTHONPATH (either/both inside the Anaconda GUI package manager, and in the Unix shell .bashrc/Windows environment settings).
See the anaconda doc and also SO and the many good third-party blogs out there.

Jupyter notebook doesn't see the environment's packages

I want to follow along a course about deeplearning. This course has a github repo, where all of the codes are available. We need to use anaconda, create an environment based on the yaml file, and run a jupyter notebook within that environment.
There's even a test notebook to check whether the installation and environment creating process was successful. I have created the environment as the description said, the installation of the packages seemed to be good.
For the first few command, I get the required outputs, but the notebook doesn't seem to start from the correct environment, it gives me
C:\Users\user\Anaconda3\Lib\site-packages\jupyter.py
instead of
C:\Users\paperspace\Anaconda3\envs\ztdl\lib\site-packages\jupyter.py
And it can't find the packages that I have just installed before. For example, when it has to include sklearn it gives me:
No module named 'sklearn.__check_build._check_build'
Installing them from command line with pip/conda solves this.
I have tried to install manually ipykernel, nb_conda, jupyter as other posts say. I ran jupyter notebook after I activated the conda environment from the anaconda prompt. But none of these helped me. As I open the kernel menu, I can see that the proper ztdl anaconda environment is the active one.
I also removed anaconda from the %PATH%, and added it again afterwards with c:\Users\user\Anaconda3\ .
I have no idea what should I do to run the notebook within this given anaconda environment, so I can access the installed packages. Thanks in advance, any help is appreciated.

Unable to start Spyder after conda update/install packages?

I was playing around with Spyder today, and ran ONLY the following in the cmd window:
conda update scikit-learn
conda install matlibplot --force
Both ran successfully, to completion. Now, all of a sudden, Spyder doesn't start after updating one package and installing one package. I rebooted my machine; sitll can't gte Spyder to run. Is there some kind of master reset, or some trick to manually get Spyder to statup? Thanks to all.
When I reun 'spyder --reset', I think it's supposed to reset everything. That's what I'm seeing from various posts. When I enter that into the Anaconda prompt, all I get is 'Python has stopped working. Windows is checking for a solution'. Then I have to close the error prompt, and that's then end of it. There should be an easy way to fix something like this. Literally, all I did was upgrade 2 packages. There's no way Python can be this unstable, or fragile.

jupyter doesn't import numpy after upgrade with anaconda

I updated the packages with conda update --all and was using jupyter to work. Before the update, everything was working, but now jupyter doesn't import any module beside the sys, os, copy and time. Numpy, matplotlib and theano are not being imported. But they are definitely in the conda list... the python version is 2.7.12
When I updated with conda, I remember that there was a message that numpy was being deprecieted due to conflicts. Now in the conda list I have numpy 1.11.1.
I'm new in python, so I don't understand the import error. Before uninstalling everything again, I would like to understand what the problem is to learn and of course to continue using jupyter ;)
I found this post https:// github.com/jupyter/notebook/issues/397 (sorry I can't link it, I'm new here) which seems to be a problem related to mine or similar, but I don't think I understand it so well... so before I break more I wanted to ask here!
Is jupyter badly "connected" to anaconda? How can I check where the packages are being searched? For any comment on this I would be very grateful!!
Here are the cells of jupyter:
cells of jupyter
and the Error I get:
ImportError
Thanks!
That import error is due to change in environment of the jupyter notebook. You might have installed the packages in one environment and you are running the jupyter notebook in another environment.
I have got two environments (envs) in my Anaconda folder. I have Anaconda3 folder to be specific).
(windows key+cmd) -> open the windows command prompt run as administrator.
Activate (name of the environment) -> eg.: activate tensorflow-gpu
Start installing packages using conda install
Note: For each environment you need to install all the packages you want to use, separately using the same process. This solution is for windows users, might work for linux users not sure though.
Additionally to make sure your conda environment is up to date run:
conda update conda
conda update anaconda
For more information: https://pradyumnamajumder.wordpress.com/2017/09/30/solution-to-the-python-packages-import-error-in-jupyter/
I followed the idea as in here and changed the file that launches the root jupyter command (cf. cat /dir_where_installed/anaconda2/bin/jupyter and the jupyter-notebook ( cf. cat /dir_where_installed/anaconda2/bin/jupyter-notebook).
It was set as in the anaconda environment conda info --envs as expected (both files had in the first line something like #! /dir_where_installed/anaconda2/bin/python), but for some reason after the update I did and even after installing again everything(!), jupyter wasn't taking that path, instead it was importing from the 'stock' python (apparently).
Anyway, I changed both lines with #! to take the path as in the output of which python.
Summary:
check path in cat /dir_where_installed/anaconda2/bin/jupyter and cat /dir_where_installed/anaconda2/bin/jupyter-notebook
which python out put should be something like /usr/bin/python
substitute the lines in both files starting with #! with #! /usr/bin/python
I'm not sure if this is a good idea, but it worked for me and now I can import all packages in jupyter. If anyone has any idea if this is a bad idea or a better solution, please let me know!

Categories

Resources