How to fix : Prefix "100" in front of all Anaconda packages - python-3.x

There is a prefix of "100" in front of all my python packages in anaconda navigator. I believe this is making it difficult for applications to use these libraries. For example, I cannot open Spyder.
Packages will be listed as "100 numpy" rather than simply "numpy"
I was in the middle of creating a virtual environment seperate from the root folder but I was doing a few install / uninstall of different packages using both Navigator and Anaconda Prompt. Suddenly just about everything with my python installation started having problems. After closing Spyder I have not been able to reopen it. I tried spyder --reset which did not work. I've tried several complete reinstalls of Anaconda and each time my root installation (as well as any other venvs I create) have a prefix of 100 in front of the package name.
I would expect the packages to read "numpy" rather than "100 numpy" etc.

I have also experienced this issue. For me, this occurred after running conda update --all in the anaconda terminal. I was able to fix this by rolling back my conda version to the version prior to my update that broke it.
To do this, go to anaconda prompt and type in conda list --revisions to find the revision number prior to whichever update broke anaconda. They you just type in conda install --revision #, replacing "#" with the revision number.

The same happened to me, however, it didn't affect Spyder. It occured after I added the conda-forge channel. After updating all packages using conda update --all, all packages were updated from the conda-forge channel.
I fixed this by removing conda-forge from my environment's channels and updating all packages using above command, which actually 'downgrades' a lot of packages that were more recent in the conda-forge channel. You can do this, by using:
conda config --remove channels conda-forge
afterwards, do
conda update --all
If this is your problem and you want to keep conda-forge because the base channel doesn't include the desired package, appending it to your channel list should work, instead of giving it highest priority, by using
conda config --append channels conda-forge

Related

MAC OS Unable to update, uninstall, pip install, sudo, conda prompts, always get "An unexpected error has occurred."

I have come to find out that I have several Python paths. Using Jupyter, SQ, I cannot find anyway online that shows me exactly my issue and resolving my path issues.
I have done all the below and then some. No matter what I try it gives me the same issue, "An unexpected issue..." I need conda and my environments and Conda will not open. I really need help removing Python paths and getting Conda to work again. The following shows my Python paths in VS code and I found the paths below that to be my 2 main paths in Jupyter. (Kernel dies as well) I'm am new to data analysis and I have followed the download instructions for all my lessons to the exact click. I have been having this issue for a few weeks, I have tried multiple terminal prompts, unfortunately I cannot remember them all. All of them are from stack.
pythondata /Users/me/Library/Jupyter/kernels/pythondata
python3 /Users/me/opt/anaconda3/share/jupyter/kernels/python3
Path=
import sys,os (tried changing or adding files)
conda info
conda list
conda install/uninstall
conda update
sudo chown...
sudo conda update (-n base conda, anaconda-navigator, navigator-update)
pip installs
conda install python=3.6
conda config --set allow_conda_downgrades true
conda install conda=4.6.14
at least 20 other commands, I started writing them down today...
I have really tried A LOT and all of these commands I get unexpected error.

Conda vs. pip under Spyder

I have a 2-part question about conda vs. pip virtual environments. I found great information on the answers What is the difference between pip and conda? and Does Conda replace the need for virtualenv? but still have something unclear.
I have a given python project (say PR) that I need to install and further develop on a linux server (say S) where python is installed with anaconda. Now, the usage/installation instructions of PR tell me to use python to create virtual environment and pip to install all packages. That is,
python3 -m venv PR
pip install --editable . (the dot included at the end)
According to "pip install --editable ./" vs "python setup.py develop" the latter reads the file setup.py (included in PR) which contains a function setup(...) with option install_requires listing all the required packages and installs them automatically. I have tested this on my own computer (which does not have conda) and it works fine. At least no error messages.
Now I need to further develop PR on S. My question Part 1: can I use conda instead of pip to create and update virtual environment? If yes, what would be the conda command replacing pip install --editable . ? I'm positive I will later need to install other packages as well. I'm worried about conflicts between conda/pip.
On S, I have Spyder and no other python IDEs. I have never used Spyder but I'm very familiar with PyCharm (Windows) and VS Code (Linux) so I assume debugging with Spyder will be similar to those. My question Part 2 (tied to Part 1): if I have to use pip to install packages, does Spyder see those? Or can it only see conda-installed packages?
(Edit/update): Thank you Carlos for comments. I continue my question:
I created and activated the virtual environment (VE) with conda
conda create PR_venv
conda activate PR_venv
Installed pip with
conda install pip
(this upgraded pip and installed several other packages too, including newer version of python). Installed PR and its required packages with pip
pip install -e .
Now, if I run the PR package inside this active VE interactively from the terminal, everything works fine. I would like to do the same from within spyder, to get the IDE debugging abilities in my hand.
When I start spyder, open a python file to be run, click "Run" button, it crashes in the import statements.
Spyder cannot see the installed packages. It can see only the local package PR but none of the packages installed by pip for this VE.
I am not sure what is the correct question here; I'm confused how are conda VEs related to spyder/jupyter/ipython ? I cannot find information in the conda documents about this.
I cannot find from spyder documents anything about VEs. Do I have to somehow re-install the packages (how?) inside Spyder? It seems pointless because the packages are installed already.
(Edit/Update 2): The information on https://docs.spyder-ide.org/current/installation.html makes me even more confused: Spyder is presented as both a stand-alone program and as a python package. So do I have to re-install Spyder inside the VE(?!) with
conda activate PR_venv
conda install spyder
Any clarification would be appreciated. I have always thought that the IDEs are stand-alone programs and that's it. This Spyder setup twists my brains into pretzel.
(Spyder maintainer here) About your questions:
can I use conda instead of pip to create and update virtual environment?
Yes, you can. Please see here to learn about the functionality offered by conda for managing environments.
If yes, what would be the conda command replacing pip install --editable . ?
Conda doesn't offer a good replacement for that command. However, you can still use it in a conda environment, as long as all you've installed all your package dependencies with conda before running it. That would avoid mixing conda and pip packages, which usually leads to really bad results.
if I have to use pip to install packages, does Spyder see those? Or can it only see conda-installed packages?
Spyder can work with pip and conda packages without problems. Just make sure of not mixing them (as I said above) and you'll be fine. In addition, please read our documentation to learn how to connect a local Spyder instance to a remote server.
Part 1: yes I can use conda to create VE and pip to install packages
conda create PR_venv
conda activate PR_venv
conda install pip
pip install --editable .
conda list
The last line shows which packages are installed by conda and which by pip (shown as pypi)
Part 2: spyder by default cannot see the packages. Need to do two things:
conda install spyder-kernels
Open Spyder and Tools > Preferences > Python Interpreter > Use the following interpreter > [full path to VE python command]
Restart Spyder. Now it can see the packages.
(Edit:) this link is great: https://github.com/spyder-ide/spyder/wiki/Working-with-packages-and-environments-in-Spyder

How do I "build with the CLI option" with conda-build?

I am new to Python, the Anaconda environment, conda, pip, all of it, so please bear with me if these are simple questions. I've asked a couple previous questions about this install which so far have been resolved. Here was my previous question. All of my issues have to do with conda-build meta files which don't work and need some hand-editing in order to succeed.
Background:
I am trying to install the package called ibm-watson in my Python, in a separate conda environment cloned from my base environment. This is in support of a Coursera course. The courseware builds this package in its own Jupyter window with a pip install. I wanted to build the examples in my own environment, and I'm working in Anaconda at the recommendation of many people.
When I first ran into issues with conda-build which I couldn't figure out, I decided to try pip. That worked, but led to other problems (which online articles warned about). Conda (I read) doesn't know about things installed with pip, and that screws up its ability to manage packages and environments. So I decided to back out the pip install and try to make it work with conda.
First question: Why does pip install work correctly and recursively build all dependencies but conda-build does not? Am I just not using the right options for conda?
So here are the meta.yaml issues I've uncovered so far and resolved with the help of people here.
Version string that said '>=2.0,' with an extraneous comma.
package name that was shown with underscores but actually needed hyphens
Dependencies which I fixed by downloading the required packages one by one and building, frequently dealing with the same issues above in the meta.yaml
Most recently, this string, which was throwing an error till I guessed that the quote marks were the issue: typing; # [ py <'3.5' ]
Also the install command from the conda documentation conda install --use-local my-package doesn't work, and per a discussion on Github, I am instead using conda install -c ${CONDA_PREFIX}/conda-bld/my-package
Second question: Why is the conda process so buggy? Are the IBM developers just careless in their testing or is it conda that's at fault or am I using all of this wrong?
And finally, the real question
The last dependency I had to build was python-dotenv installed from PyPi. I built that with conda like the others:
conda skeleton pypi python-dotenv
conda-build python-dotenv (after making the above change to meta.yaml)
That gets all the way through building but then throws this error:
Run pip install "python-dotenv[cli]" to fix this.Tests failed for python-dotenv-0.11.0-py37_0.tar.bz2 - moving package to /Users/(myname)/opt/anaconda3/envs/coursera/conda-bld/broken
Since I'm not using pip, how do I do what it's asking me to do? I tried just doing conda-build "python-dotenv[cli]" but got "no valid recipes for python-dotenv[cli]".

How to set up Anaconda so that it doesn't affect other environments like 'homebrew python pip' and Pyenv on MacOS?

It is well known that Anaconda installation on macOS can cause trouble with other widely used package/environment managers like Homebrew, Pyenv, Virtualenv, etc.
The majority of the solutions I've found are 'Anaconda-centric', i.e. using Anaconda as the main python manager and setup conda env for homebrew etc.
However, I am looking for a solution that's kind of 'Homebrew-centric', and setup Anaconda as a compliment. Anaconda should be set up in a way that when ever conda is used, it will work with its own Python, own packages. And leave the rest of system untouched.
The motivation for such solution is because that, for example, when one's main work-flow use homebrew Python3 (python3), homebrew pip (pip3) and Pyenv (pyenv) with requirement.txt. And occasionally using Anaconda when a project is required.
Rather than using Anaconda I would suggest using Miniconda, which includes only Python and conda (and a few support packages). Miniconda does not include all of the packages in Anaconda by default, but they can all be installed (with conda install anaconda). Once you download Miniconda, you can install it into your home folder at /Users/username/miniconda3. During the installation, you will be asked if you want to add some initialization code to your .bash_profile. Either choose yes or (if you chose no), then you can run
/Users/username/miniconda3/bin/conda init
to add the conda initialization to your .bash_profile. By default, this will activate the base environment, so you can change the default setting so the environment is not activated by default:
conda config --set auto_activate_base false
You'll probably need to open a new terminal so the conda command is available. Then, when you want to use a conda environment, you can conda activate that environment, but otherwise, conda's Python should not be on your PATH.

Update Biopython in Ipython shell

python newbie here, today I updated biopython to v1.70. I use spyder/IPython shell for most of my work. if it makes any sense, the version of biopython seems updated in the python console (spyder), and windows command terminal python installation, but IPython console is still showing older version. Should that be updated separately, and if yes, how. Thanks for answers.
For Anaconda on Windows, using the Command Prompt (what you get when typing cmd or clicking on Command Prompt in the Start menu) is discouraged1 since the latest release (May '17).
Instead, use Anaconda Prompt or the graphical Anaconda Navigator (both located under the Anaconda folder in the Start menu). You should use them for installing packages, as well as for running apps (e.g. Spyder, IPython).
Also, I recommend you use conda to install packages. conda is the native package manager for Anaconda, and it manages dependencies (packages required to run other packages) better than pip.
So, what you can try is:
Start --> Anaconda Prompt, and then
conda install biopython
ipython
At the time of writing, the official conda repository contains biopython 1.6.9. If you really need 1.7.0, use conda install -c conda-forge biopython (conda-forge is an alternative package repository which is maintained by the community).
[1] See the 2nd bullet on Anaconda 4.4.0 release notes.

Resources