I am not able to install pytorch in jupyter and Spyder? - python

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.

Related

why does pip export with a different version on subsequent conda env exports?

I have been trying to establish a pre-commit git hook to detect environment changes and create a new env.yml export automatically ... similar to the ones described here
Where I am having trouble is that the git hook is detecting an environment change with the pip package on every run of the pre-commit file. Is this possibly related to some scripts using different versions of pip?
If so, I don't understand why the same version isn't being exported every time I run conda env export > env.yml. It almost seems like it is randomly toggling between versions ... but I know there must be some rationale
conda and pip have their own versions of every package installed (provided that you have installed a certain app using both). anaconda (if it's what you're using) is also known for giving plenty of headaches even in simple cases when you pip install something instead of conda install and start mixing dependencies installed with either of those. The general advice is to be very careful about being consistent with each environment separately. In my personal experience, anaconda always tries to superimpose itself by by breaking dependencies managed by pip. In short, if you are using a conda env, make sure that you're using the dependencies installed by conda and conda only.

Miniconda doesn't activate

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.

Update kernel modules after Spyder update

I updated my Spyder today to Spyder 5.1, and now it keeps showing me this error message:
Your Python environment or installation doesn't have the spyder‑kernels module or the right version of it installed (>= 2.1.0 and < 2.2.0). Without this module is not possible for Spyder to create a console for you.
You can install it by running in a system terminal:
conda install spyder‑kernels=2.1
or
pip install spyder‑kernels==2.1.*
I already tried both commands, the pip one works but I still get the error message, the conda command does not even work and shows me
The following packages are not available from current channels
Normally I use conda for all packages that are availabel on conda, so maybe someone faced the same issue?
Version 2.1 is only available through Conda Forge at this time. Try
conda install -c conda-forge spyder-kernels=2.1
So far I've had to remove spyder-kernels from any env from any env that has it before I'm able to get it to install on any other env. I'm using conda. It seems I can't have more than one env available for use without constantly swapping where spyder-kernels is installed. This is the case for Windows 10 and MacOS. The spyder docs say to just ignore the issue - and that it was allegedly fixed by now - but I don't know how to ignore an error that makes it impossible to start a python console.
Correction: After erasing all envs and starting over from scratch (zero envs), I am now able to install spyder-kernels on multiple newly-created envs and each one functions in console without an issue.

Why does Anaconda Navigator (Windows) show a different version of Tensorflow than the command line?

I recently created a new Anaconda (Windows) environment in order to move from tensorflow 1.2 to tensorflow 2.0. My base environment is 1.2, and I created tensorflow-20 in order to install the new version. I did the install from the anaconda command line within the (tensorflow-20) environment. But now everything is messed up.
Now, in Anaconda Navigator, it still shows Tensorflow 1.2.1 as the installed version for base. But in the (base) environment from the Anaconda command line, it shows the version as 2.0.0. Furthermore, in Anaconda Navigator, tensorflow-20 shows no installed packages, including python even.
I feel like I'm fundamentally misunderstanding something here. Can anyone provide some guidance?
How did you install tensorflow 2.0 in the new conda env?
IF with pip, run 'where pip' see if you are using the pip installed
in the base env. You can run 'conda create -n tensorflow-20 pip' to get a pip installed in the new env. Then activate tensorflow-20 and install tensorflow 2.0 with pip.
IF with conda, run 'where conda' to check the same thing.
Preface:
If you install Anaconda on your local machine, it makes sense to install it as Admin. However, if this is not possible, e.g. on an enterprise-managed computer, you must carefully check to use only folders where your user has write permission.
Contribution:
After having experienced a cracked-up package management, I read deeper into that topic. Best Practise: Always try to install everything via conda / Anaconda and best possibly from their central repositories.
If you have a special package, which is e.g. built by local software developers and not published, you can install it from the .tar archive. At that point, I am referring to following documentation: https://docs.anaconda.com/anaconda/user-guide/tasks/install-packages/

Scikit-learn - installing development version (0.20)

I currently have scikit-learn 0.19 installed. I'd like to test my code using the latest development version as there seems to be a fix for Incremental PCA.
How do I go about installing this new version if I've previously installed scikit-learn using anaconda?
Also, how would I revert back to the stable release in the event that 0.20 does not solve my problem?
I am in need of some hand holding here, as I've read the docs on the website and not sure I completely understand the process (especially being able to revert back to the stable version if needed).
The whole point of the Anaconda Python distribution (apart from the convenience of having a bunch of useful packages included) is that you get the conda environment manager, which exists to meet exactly this sort of requirement.
What you want to do is to create a new conda environment by launching the Anaconda prompt and typing
conda create -n myenv scikit-learn other-package other-package2 etc
where myenv is the name you want to give the new environment and other-package other-package2 etc are the names of any other packages you will want to use (import) in your code. conda will figure out any dependencies of these packages and show you a list of what is going to be installed before it proceeds.
If you want to specify that a package should be a particular version, add that to the package name e.g. other-package=1.1.0, otherwise conda will install the latest versions of each package that are mutually compatible. You can also specify a particular version of Python by including it in the package list, e.g. python=3.4. You can check what versions of a package are available with conda search package-name (where package-name is the name of the package you want, obviously).
To run your code in the newly created environment, first activate the environment at the Anaconda prompt. If you use the Spyder IDE, launch it after activating the correct environment, or use the start menu shortcut specific to that environment if you have one. Other IDEs may have their own method of selecting a specific environment to work in.
To revert to the version(s) you were using before, activate the environment containing those versions - if you've never created a new environment before, that'll be root.
Just in case someone comes here looking for a solution without conda:
The website recommends that you download the latest code via
git clone git://github.com/scikit-learn/scikit-learn.git
and then include it in pip via (after changing to the directory)
pip install --editable .
You can also add the --user flag to have pip install to a local directory. Then, uninstalling should be as easy as pip uninstall sklearn.

Categories

Resources