I tried to install Conda on Kali Linux. I used the command $ pip3 install conda after that i try to run anaconda but nothing happen, so I go to the website and install the anaconda for linux64 then I install it successfully but when i run the script
$ source /home/faidey/anaconda3/bin/activate
$ conda init
The following message appears:
conda init
no change /home/faidey/anaconda3/condabin/conda
no change /home/faidey/anaconda3/bin/conda
no change /home/faidey/anaconda3/bin/conda-env
no change /home/faidey/anaconda3/bin/activate
no change /home/faidey/anaconda3/bin/deactivate
no change /home/faidey/anaconda3/etc/profile.d/conda.sh
no change /home/faidey/anaconda3/etc/fish/conf.d/conda.fish
no change /home/faidey/anaconda3/shell/condabin/Conda.psm1
no change /home/faidey/anaconda3/shell/condabin/conda-hook.ps1
no change /home/faidey/anaconda3/lib/python3.8/site-packages/xontrib/conda.xsh
no change /home/faidey/anaconda3/etc/profile.d/conda.csh
no change /home/faidey/.bashrc
No action taken.
So when I try to do the script $ sudo conda init the following message appears:
ERROR: The install method you used for conda--probably either `pip install conda`
or `easy_install conda`--is not compatible with using conda as an application.
If your intention is to install conda as a standalone application, currently
supported install methods include the Anaconda installer and the miniconda
installer. You can download the miniconda installer from
https://conda.io/miniconda.html.
What can I do to remove the effect of first script $ pip3 install conda and run anaconda successfully?
Which shell are you using? As the .bashrc is already modified by conda, you should be able to use conda as normal user. Maybe you have to restart the shell. If you are using zsh or another shell, you might have to modify the configuration manually.
If you really want to use conda as root user, you could try the following steps:
You could try to remove the pip version of anaconda calling $pip3 uninstall conda. Now $conda init should work as root user. If not proceed with step 2.
You could try to find out which binary is the correct one by calling $which conda as normal user and use the absolute path to initialize conda.
Related
I am currently working on a python project using Visual Studio Code and Conda. When I try to install a package in the virtual environment it does not work (details and steps below). But if I use my computers command prompt and install that way, it does work in the virtual environment.
My steps are as follows:
I created a virtual environment as so:
conda create -n envname
Activated the environment:
conda activate envname
Tried to install a package (i tried to use conda install but package wasnt found):
pip install packagename
Then write it into my code like so:
import packagename
Which throws me this error:
ModuleNotFoundError: No module named 'packagename'
I did try the solution from this page and tried installing the package this way:
C:\Users\myname\anaconda3\envs\envname\Scripts\pip install packagename
but it returns this:
Requirement already satisfied: packagename in c:\users\name\anaconda3\envs\envname\lib\site-packages
when i type:
conda list
The package I installed is included, as well as pip. However, the package I installed shows the version # in one column, then only "pypi_0 pypi" in the last column. not sure if that means something is wrong or not.
packagename 3.41 pypi_0 pypi
As mentioned, if I type this in my computers command prompt (separate from VSC and my virtual environment):
pip install packagename
My virtual environment will pick it up as being installed.
I feel all mixed up lol, like some path somewhere isnt right but I cant figure out what
Any ideas?
No Need to explicitly activate the venv
Try using following commands.
Step 1: Create virtual env
python -m venv envname
Step 2: Switch to this newly created virtual env
Windows
.\envname\Scripts\activate
Unix
source envname/bin/activate
Step 3: install packages in the virtual env directory
pip install <packagename>
I am trying to update matplotlib but getting an error. Error message : EnvironmentNotWritableError: The current user does not have write permissions to the target environment. environment location: C:\Users\DeepakKumar\Anaconda3 How to fix this issue?
Some Specs:
Anaconda3 2019.10
Python 3.7.4 64-bit
matplotlib 3.1.1
If you are using Windows, try to open your shell as an administrator and then run pip/conda install that will install it.
Also, I highly recommend using virtual environments to install libraries and avoid conflict in dependencies.
You can use virtualenv: https://virtualenv.pypa.io/en/latest/
Or conda management environemnts.
Basically, you create a new environment:
conda create -n my_env
conda activate my_env
conda install matplotlib
This will avoid these kind of problems.
You can also read more about it here: conda-envs
Search for Anaconda Prompt, Run the Prompt as Administrator (Right Click and select Run as Admin), then use conda update <package>, this shall solve your current issue, but this is just a workaround.
As Admin you should run conda update -n base -c defaults conda. This way your Anaconda should now update without admin related errors.
I'm trying to work with pipenv and I installed it using pip, however whenever I run any command starting with pipenv, I get the following error:
zsh: command not found: pipenv
I know I should add it to my path somehow but I'm not entirely familiar with how to configure my ~/.zshrc.
Also, I tried locating where pipenv is located using where pipenv, but I get
pipenv not found
You will need to add support to your ~/.zshrc file. You can access it with code ~/.zshrc.
I needed to add these to the file:
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
export PYTHON_BIN_PATH="$(python3 -m site --user-base)/bin"
export PATH="$PATH:$PYTHON_BIN_PATH"
Once you add them you will need to restart your terminal before you can see these changes take effect.
Using pip
pipenv should be in your PATH if you installed it using pip as a user install, as recommended in the docs:
pip install --user pipenv
If it still isn't available, you'll need to add the user base's binary directory to your PATH:
UNIX default: ~/.local
MacOS Framework builds: ~/Library/Python/X.Y
Windows: %APPDATA%\Python
You can read more about this in the Python docs on site.USER_BASE.
Using Homebrew
If you're using Homebrew, then another option is to install pipenv like so:
brew install pipenv
This installs it globally. Since pipenv can manage even different python versions via pyenv, it's preferable to have it set up like this instead of installing it only for a specific python version using pip.
However, this method is discouraged according to the pipenv documentation:
Homebrew installation is discouraged because each time the Homebrew Python is upgraded, which Pipenv depends on, users have to re-install Pipenv, and perhaps all virtual environments managed by it.
Use a package manager such as apt, yum or brew to install pipenv.
Installing pipenv with a package manager rather than pip adds it directly to $PATH of any shell, like bash or zsh.
sudo apt install pipenv
Open ~/.zshrc and append these lines:
# Setting PATH for Python 3.4
PATH="/Library/Frameworks/Python.framework/Versions/3.4/bin:${PATH}"
export PATH
or:
# Setting PATH for Python 3.9
PATH="/Library/Frameworks/Python.framework/Versions/3.9/bin:${PATH}"
export PATH
I tested it on macOS.
I'm trying to follow this tutorial:
https://learn.microsoft.com/en-us/azure/machine-learning/service/tutorial-data-prep
As part of this I'm trying to do a pip install of azureml as it's not available on conda. However doing a pip install will by default install it to my default python install, and not my conda install.
So I tried following the steps here:
https://conda.io/docs/user-guide/tasks/manage-environments.html#using-pip-in-an-environment
However after following these steps I then launch Jupyter notebook after activating myenv, navigate to the notebook, and try and run:
import azureml.dataprep as dprep
But get the error: ModuleNotFoundError: No module named 'azureml'
Also - I cannot tell if myenv is active in the notebook. The kernel simply says python3.
Be careful, when using pip in anaconda, it is possible that you are mixing pip and pip3.
Run which pip3 to be sure you are using the version that correspond to the virtual environment.
If you are using python3 in the environment, then pip will typically be the correct version to use. Do not use pip3 in that case.
This problem has been documented elsewhere on the web. The problem is that Jupyter notebooks itself only launches in the root environment by default. The simplest solution to getting it to launch for your env (e.g. myenv) is to install Jupyter within your env first. So from the Anaconda command prompt:
activate myenv
pip install jupyter
jupyter
Ps. Use source activate myenv for non-windows machines
Sorry if I am unclear/this is a lame question, still very new to setting up my computer.
So I installed Python using Anaconda for work, and at work there are specific packages that are used internally. I used Anaconda Prompt to install these packages by creating an environment and installing internally used packages. I then check to see if the package is there.
In the Anaconda Prompt...
conda create --name environment_name python = 3.4
activate environment_name
pip install <internal package> --upgrade
pip list
However, when I try to import a package on Spyder, it does not recognize the package. Is there a way for Spyder to run code on an environment that I specify? I would like the environment to run automatically on any file that I run using Spyder, being able to pull the packages that I installed on Anaconda Prompt