I have no access to the folder with Anaconda environments on some pc.
Can I temporarily set the environment path to be different from the default one?
UPD:
I've tried conda activate ./Desktop/My_env
And it is ok. But when I'm trying to launch the jupyter notebook I get the error:
-bash: /home/username_on_the_other_pc/My_env/bin/jupyter: /home/my_local_pc_I_have_rights_to/anaconda3/envs/My_env/bin/python: bad interpreter: No such file or directory
if you are on linux or mac .. just try source path/bin/activate. It should activate the environment. Let us know if you have any issues with that command.
Related
I am following the tutorial on MLFlow website. I was able to run the train.py and mlflow ui worked fine. Packaging the project tries to use env variable MLFLOW_CONDA_HOME but can't find conda.
I have tried setting the variable to the path of anaconda3/condabin but it doesn't seem to find my executable. This is the error I get:
ERROR mlflow.cli: === Could not find Conda executable at /anaconda3/condabin\bin/conda. Ensure Conda is installed as per the inst
ructions at https://conda.io/docs/user-guide/install/index.html. You can also configure MLflow to look for a specific Conda executable by setting the MLFLOW_CONDA_HOME environment variable
to the path of the Conda executable ===
Adding \bin/conda at the end of my path seems to be the problem, I am not sure why mlflow is doing it. I even tried setting it to my python.exe in my conda env, but no luck. I can't find bin/conda folder in my Anaconda folder anywhere.
I resolved this by running it from Anaconda Prompt. Make sure mlflow is installed in anaconda first as well, nothing else. But the problem then is that it's not well compatible on windows, you would need to split into two steps, activate the conda environment and then run with --no-conda as mentioned here https://github.com/mlflow/mlflow/issues/2674
MLflow 1.5 was just released today.
It doesn't specifically mention it in the github notes, but I had the same issue, where it affixed \bin/conda, and now it doesn't do that anymore.
If you don't have conda environment then you can execute the following command from your terminal
mlflow run <enter your local directory name> --no-conda -P alpha=0.5
This should solve the issues with the environment variable.
I solved the issue by removing the MLFLOW_CONDA_HOME environment variable alltogether. Make sure you have added the path to the conda executable to your PATH variable.
Here is one possible solutions (the fastest one, in my opinion).
Key points:
The project virtual environment should be created with conda.
Use pip to install MLFlow.
Follow the steps for Windows:
Install miniconda (in my case, version 3)
Set conda bat file (installation path + condabin dir + conda.bat) in PATH
Create your project without virtual environment (in my case, I set in PyCharm conda instead of venv and it did not create any virtual environment, just added some external libraries), at least not in the project directory.
Create conda virtual environment manually in the project directory. In your project directory, execute conda create -n venv and follow the instructions (I used default for all the questions there).
Open a terminal and activate conda virtual environment. If you use PyCharm, you will be positioned properly, otherwise just prompt yourself in the project directory. Execute conda activate venv where venv is my virtual environment created at point 4.
Execute python -m pip install mlflow
If you want to test it, you can try one of the tests from MLFlow. E.g., you can use mlflow run https://github.com/mlflow/mlflow-example.git -P alpha=5.0
In my case, it worked.
If you're using mlflow.pyfunc.spark_udf and get an error saying Could not find Conda executable conda then try to define the environment variable MLFLOW_CONDA_HOME in spark-env.sh as Spark doesn't recognize variables defined elsewhere. Also make sure to use the absolute path for the Conda executable.
I faced this issue within a kubernetes deployment with miniconda3 as the base image. Fixed this by setting the MLFLOW_CONDA_HOME env variable to "/opt/conda/"
I've been told that to activate a Virtual Environment in Django for Windows I should try:
environment_path\Scripts\activate
But when I enter that, cmd returns this error:
The system cannot find the path specified.
I created the virtual environment by entering:
python3 -m venv env
However when I try env\Scripts\activate I get the error described.
Can anyone help? Thanks.
Activating a virtual environment on Windows depends on where you are running it from. From the Windows Command Prompt, the command is:
environment_path\Scripts\activate.bat
If the Git-Bash shell is being used, which adds several useful tools and a more Unix/Linux-like environment, then the command is:
source environment_path\Scripts\activate
I have found the prerequisites section of Test-Driven Development with Python aka "the Testing Goat book" to be handy in getting Django, Python and related things setup on Windows.
You can create virtual environment in windows as:
py -m venv myenv (Here myenv is the name that users give. It can be anything you want)
Now to activate your myenv virtual environment type:myenv\scripts\activate
To deactivate virtual environment simply type:
deactivate
If you are using windows 7, then try environment_path\Scripts\activate.ps1
Also, error is saying, The system cannot find the path specified., make sure your path is correct.
Remember scripts folder is in your virtualenv folder.
I am having trouble adding conda to my environment variables on windows. I installed anaconda 3 though I didn't installed python, so neither pip or pip3 is working in my prompt. I viewed a few post online but I didn't find anything regarding how to add conda to my environment variables.
I tried to create a PYTHONPATH variable which contained every single folder in Anaconda 3 though it didn't worked.
My anaconda prompt isn't working too. :(
so...How do I add conda and pip to my environment variables or path ?
You can access to conda and pip directly in their directory :
On Windows : %ANACONDA_INSTALL_DIR%\Scripts, you will find conda.exe and pip.exe
On Linux : $ANACONDA_INSTALL_DIR/bin, there are conda and pip executable files.
Where $ANACONDA_INSTALL_DIR is the directory of your Anaconda installation.
To add Anaconda to your path, you can add this folder to your PATH.
For Linux, you can add this line to yout .bashrc file
export PATH=$ANACONDA_INSTALL_DIR/bin:$PATH
As said #BcK, reinstalling Anaconda and choosing to add Anaconda to your path is also a way to do this. This option makes a backup of your .bashrc file and add the export line.
EDIT
To open a terminal with the conda environment activated on Windows, I usually create a desktop shortcut with the following target :
%windir%\System32\cmd.exe "/K" %ANACONDA_INSTALL_DIR%\Scripts\activate.bat %ANACONDA_INSTALL_DIR%
Thanks guys for helping me out. I solved the problem reinstalling anaconda (several times :[ ), cleaning every log and resetting the path variables via set path= in the windows power shell (since I got some problems reinstalling anaconda adding the folder to PATH[specifically "unable to load menus" or something like that])
I have created a virtual enviroment using virtualenv command with a standard procedure. Now, when I activate it or deactivate, the output of which pip or which python gives me same output /usr/local/bin/pip. However there is copies of python and pip commands in my vitrual enviroment directory - I have found them there. What might be the problem?
Did you move the virtual environment folder to a different name? The original path to the virtual environment is written into the generated activate script so if you move the environment activate will set your path to the old path of the virtual environment.
To fix this run virtualenv --relocatable $YOUR_VIRTUALENV_PATH then modify the VIRTUAL_ENV variable in the activate script to point to your new location.
I think it happen when I moved the environment folder to a different location.
I solved it by reinstalling virtualenv and creating a new environment
I am new to Anaconda Python and I am setting up a project in Sublime Text 3. I have installed Anaconda and created a virtual environment using:
conda create -n python27 python=2.7 anaconda
conda create -n python35 python=3.5 anaconda
I am having trouble setting up the Virtualenvs plugin for SublimeText 3.
When I try, it asks me for a virtualenvs path which I give:
~/users/../anaconda/envs/python27
Then it asks for what I'm assuming is a path to a python distribution because it lists file paths for the system versions of python -- but not the anaconda install.
I have no real desire to use the plug in, I just want to be able to use both versions of python. Could I use a project settings file to set the version of python instead?
If you activate the environment you're interested in, you can find that answer in the environment variables.
on MacOS/Linux:
source activate python35
echo $CONDA_PREFIX
on Windows:
conda activate python35
echo %CONDA_PREFIX%
You can also run conda info --envs, and that will show the paths to all your environments.
To get the path to the instance of python being used by a particular environment, do the following:
on MacOS/Linux:
source activate python35
which python
on Windows:
conda activate python35
where python
That should return the path you're looking for.
You can run the command conda info.
This will output something like this:
envs directories : C:\Users\Geo\.local\Miniconda3\envs
C:\Users\Geo\.conda\envs
C:\Users\Geo\AppData\Local\conda\conda\envs
I have installed conda at C:\Users\Geo\.local\Miniconda3.
Then with the command conda info -e you get the location of each environment.
(base) C:\Users\Geo>conda info -e
# conda environments:
#
miniconda2 C:\Users\Geo\.conda\envs\miniconda2
base * C:\Users\Geo\.local\Miniconda3
anaconda3 C:\Users\Geo\.local\Miniconda3\envs\anaconda3
ml C:\Users\Geo\.local\Miniconda3\envs\ml
Your environments are located in Anaconda3\envs\<yourEnv_directory>\
To answer your question the folder for your python binaries and packages for the environment are located in ~Anaconda_installation_folder~/envs/python35.
But I cannot really say if that solves your problem. Normally you just switch to your environment source activate python35 and then type python. This will automatically give you the "right" python executable. So if you have a package you could use:
source activate python35
python setup.py install
# Now it is installed in your python35 environment
source activate python27
python setup.py install
# Now it is also installed in your python27 environment
Just change python setup.py install to what you want to do in the environment. I don't have any experience using Sublime Text and what you mean with build system. But you can always use something like tox which automates a lot of these manual builds.
None of the other windows solutions worked for me so I'm providing my own. Activate the environment inside anaconda prompt, then issue the command 'where python' and you'll likely see multiple results but one of them, most likely the top one, is the one you're after. For me, my environments were located in AppData\Local... which is not what anyone else had mentioned but the best solution is to use 'where python' which should result in an answer regardless of how you've installed Anaconda.
For me, with default anaconda settings and Windows 10, the path that displays after activating the environment is C:\Users\usrname>, but it does not contain an Anaconda3 folder. However, it contains a .conda folder that contains an environments.txt file that lists all conda environments and their locations. By default, the environment folders were stored in:
C:\Users\usrname\AppData\Local\conda\conda\envs\EnvName
None of the above worked. In the end, I found mine at:
c:\Users\myusername\venvs\test1-V7fphpR9\
Open your c directory
Go to Users and then Open your naming folder (in my case Suman Biswas)
Fiend Anaconda3 folder
Fiend the folder envs in Anaconda3
Now you can see your virtual environment
enter image description here
enter image description here
enter image description here
On Windows 10 x64 and Anaconda3, the python interpreter for a newly created environment "my_env" would appear here:
C:\ProgramData\Anaconda3\envs\my_env\python.exe
Or here:
C:\Users\[username]\AppData\Local\conda\conda\envs\my_env
Check both places.
Update 2020-07-17
If Anaconda is installed as Administrator, then the default is one location.
If Anaconda is not installed as Administrator, then it appears in a different location.