How to make your default path as base for anaconda? - miniconda

I have been using anaconda(in which most things are preinstalled) for a while now but recently switch to miniconda. atm whenever I need to run miniconda I have to set the source as source ~/miniconda3/bin/activate then I would see Base in my path and conda commands works otherwise conda command does not work. Can you please guide me on how to set my source as default on mac?

Related

Starting with anaconda on Ubuntu 18.04

I installed latest version of Anaconda3-2020-02.
I was trying to follow this instruction in order to create environment for running with python==3.6 instead of python==3.7., because I have python 3.6. installed.
So, running the
conda create --name snakes python=3.6
and then activating my environment with conda activate snakes, it enters environment (snakes). However there are no anaconda packages inside like jupyter notebook or others, no anaconda-navigator... So whats the purpose of it and how can I run these programs from environment?
Also, for some reason (when I am not in the environment, just regular bash shell) $PATH is not set up to the /bin directory in anaconda, just to /condabin. Can you explain this also, because I am not able to run nothing except conda command from shell after recommended installation.
If by default after installation environment is not activated, you should activate it by sourcing a file anaconda3/bin/activate. You will see indicator (base) on the left of your bash prompt.
Good thing about anaconda3-2020-02 is that it is not messing with system python, as newest python is being launched inside environment and proper$PATH is set up just inside environment. If only, for some reason, specific version of python is needed, then it makes sense to set it up with this instruction. I would be just using default one with python 3.7 probably from (base) environment.
Keep in mind that by default anaconda components are not being set up inside new environment being created. In order to bring them, for example jupyter, you should run the command like this:
conda create --name snakes python=3.6 jupyter

Add libraries to PYTHONPATH In Pycharm (Windows 10)

When setting up a Pycharm development environment, I am trying to follow the following instruction, which is for Linux environment. However, my system is virtual environment created by Anaconda, running on Windows 10. How to add Pythonpath in Pycharm with respect to this kind of environment?
Add Libraries to PYTHONPATH
When running locally, the tensorflow/models/research/ and slim directories should be appended to PYTHONPATH.
This can be done by running the following from tensorflow/models/research/:
# From tensorflow/models/research/
export PYTHONPATH=$PYTHONPATH:`pwd`:`pwd`/slim
Note: This command needs to run from every new terminal you start.
You may follow the following steps:
Get the Python executable path for Anaconda:
Go to window's "programs" and search for "Anaconda Command line" then right click on the properties and copy the path then go to the cmd terminal and type the path and then type python.exe at the end till you logged in the python interpreter. This may vary from an OS to another but this works for me under windows 7.
In Pycharm: Add a new Python interpreter by following exactly the instructions listed in https://www.jetbrains.com/help/pycharm/configuring-python-interpreter.html.
Use the Anaconda python executable path you got in step1 for the new interpreter called "Conda" for example. Set the new project to use "Conda" interpreter instead of the normal default Python interpreter.
Apply the new changes and restart Pycharm. Open the Settings/Preferences dialog box, and click Project Interpreter page to make sure that the project is pointing to "Conda" interpreter.
Hope this will help!

Pip freeze doesnt show freshly installed packages with Pycharm

I use Pycharm to create and manage my virtualenvs in my projects.
The problem is that after adding a library with pycharm, when I type the command (pip3 freeze --user), the library does not appear in the command result.
I have to manually type the pip install command each time so that the library is visible.
What manipulation should I do in PyCharm to solve this problem?
For what you are saying, the first thing that comes to mind is that you should use:
pip freeze
And not
pip3 freeze
Because the command mapped to the pip version when you have virtualenv activated is the first. Note that for installing you seem to use pip, and not pip3
Moreover, the --user option afaik is related to the packages installed in the user folder:
--user Install to the Python user install directory for your platform. Typically
~/.local/, or %APPDATA%\Python on
Windows. (See the Python documentation for site.USER_BASE for full details.)
If your packages are installed in the virtualenv folder, I would tell you to not use that option.
Also please make sure you have your virtualenv activated. In linux you can do so by source path/to/virtualenv/activate
Edit
I understand that the reason you are using pip3 is because you may have different versions of Python in your machine. Let me explain you a bit further how it works, because version management is usually a headache for many programmers and it is common to find problems when doing so.
If you install different versions of Python in your linux machine, and you do that as root, then the installation will proceed for the whole system. Usually Python2 installation folder for Linux machines is /usr/bin/python. However, I am uncertain of which directory is used for Python3 installations. You can check that easily by doing whereis python3. You can serach the path to binary of any command by doing whereis command. Note that this works also for whereis python as far as you don't have virtualenv activated.
Aditionally, the link to the binary of a command (or the set of instructions to be exectued, more broadly) is defined in certain folders in Linux, depending on whether you created the command as root or as a user, and possibly also on the distro. This works differently in Windows, that uses the Registry Edit utility to handle command mappings. When you enable your virtualenv, what you are doing is creating an environment that enables mapping system commands such as python to the Python installation in your virtualenv folder.
When you disable the virtualenv, the command points again to the default installation path. Same happens with pip, so incorrect usage of this tool may result in different packages being installed in different locations, and therefore not appearing available for the right Python version at any given circumstance.
In Linux, environment variables are shell dependent, though you can write them out with echo $variable and set them with variable=value (from bash). The search path is simply called PATH and you can get yours by typing echo $PATH.
Source: https://askubuntu.com/a/262073/426469
I encourage you to check other questions in SE network such as this: https://unix.stackexchange.com/a/42211/96121, to learn more about this.
Addendum
Quick tip: it is common to use the pip freeze command as follows:
pip freeze > requirements.txt
It is a standard that leads to understanding that modules in such file are required for the correct functioning of your application. That lets you easily exclude the virtualenv folder when you install the program in another computer, since you can readily know the requriments for a fresh installation. However, you can use the command as you want.

Anaconda -- conda create results in "Failed to create process"

I recently installed Anaconda onto my laptop and I am trying to install a conda environment called pydecal that uses python 3.5. I have tried this in CMD as well as in Anaconda Prompt. I did not enter Python when Below is my code:
conda create --name pydecal python=3.5
I am getting a "Failed to create process." message every time I try to run the command. Anaconda installed fine in 64-bit. I am on a clean install of Windows 10. I have no other instances of Python on my computer whatsoever. I have tried running CMD and Anaconda Prompt as an administrator. I have restarted my laptop several times. Regardless, I run into the same problem. Any ideas on what is going wrong?
Did you install it on the primary drive (C:)?
My conda did not work either. I have just uninstalled Anaconda3 which was formerly installed in a secondary drive (E: rather than C:).
After installing Anaconda3 on the primary drive (C:), conda seems to work fine.
I solved it by making this way:
1: Install Anaconda in a directory structure not containing spaces.
2: Modify system environments to not include %PATH% in the user section.
I found that 'echo %PATH%' in a prompt resulted in the system defined paths, were shown twice.
3: Moved all paths containing %SYSTEMROOT% to the top search order. This was to assure the need to search obscure named paths was not searched by the 'activate' command.
Let me know if this solves your problem.
Br Michael
I solved it this way:
Opening the "Anaconda Prompt" Console Link that Anaconda creates in the start menu. As conda appeared to work fine there I copied the predefined envinronment variables for that prompt :
If you check the link, it executes this:
%windir%\System32\cmd.exe "/K" C:\tools\Anaconda3\Scripts\activate.bat C:\tools\Anaconda3
and that file refers to C:\tools\Anaconda3\condabin\conda.bat
So finally the path is specified there as :
C:\tools\Anaconda3;C:\tools\Anaconda3\Library\mingw-w64\bin;C:\tools\Anaconda3\Library\usr\bin;C:\tools\Anaconda3\Library\bin;C:\tools\Anaconda3\Scripts;C:\tools\Anaconda3\bin;C:\tools\Anaconda3\condabin;
I added that to the Windows System Environment variables and it now works properly on git bash, and other shells.
pip install pathlib
that is what i did now everything works

Windows 7: What PATH to set to when using Conda

I've got anaconda installed and was able to create a Python 3.3 environment. I can switch to it and conda info -e shows that I've switched.
However, I'm confused about what to set my PATH variable to. If I hard code it to the exact env then it works, but I thought that the purpose of conda was to be able to switch easily, as well as update and maintain various environments separately.
Perhaps I misunderstood and there's no way around setting my PATH everytime...
In the Windows cmd shell, use the activate and deactivate commands to change the PATH automatically. For instance, if your environment is called python3, run python3 to "activate" (i.e., add to the PATH) the python3 environment. Use deactivate to remove it.

Resources