How to install django in windows 10 - python

I'm using anaconda interpreter, can you please tell me how to install django by creating conda environment in different drive (other than C drive).
Thank you

You could use the -p or --prefix argument in conda create to save the environment to a specific location.
conda create -p D:/path/to/my/env django
The only difference here is that the environment will not be in the list provided by anaconda and thus has to be explicitly activated with its path.
For example this is what it looks like on OS X:
conda create -p ~/Desktop/test -y -q django
Package plan for installation in environment /Users/grr/Desktop/test:
The following NEW packages will be INSTALLED:
ca-certificates: 2017.08.26-ha1e5d58_0
certifi: 2018.1.18-py36_0
django: 1.11.8-py36hd476221_0
libcxx: 4.0.1-h579ed51_0
libcxxabi: 4.0.1-hebd6815_0
libedit: 3.1-hb4e282d_0
libffi: 3.2.1-h475c297_4
ncurses: 6.0-hd04f020_2
openssl: 1.0.2n-hdbc3d79_0
pip: 9.0.1-py36h1555ced_4
python: 3.6.4-hc167b69_1
pytz: 2017.3-py36hf0bf824_0
readline: 7.0-hc1231fa_4
setuptools: 38.4.0-py36_0
sqlite: 3.21.0-h3efe00b_0
tk: 8.6.7-h35a86e2_3
wheel: 0.30.0-py36h5eb2c71_1
xz: 5.2.3-h0278029_2
zlib: 1.2.11-hf3cbc9b_2
# conda environments:
#
Tensorflow /Users/grr/anaconda/envs/Tensorflow
cbc /Users/grr/anaconda/envs/cbc
py27 /Users/grr/anaconda/envs/py27
py35 /Users/grr/anaconda/envs/py35
root * /Users/grr/anaconda
source activate ~/Desktop/test
(/Users/grr/Desktop/test) Diouf: grr ~ $
On Windows you would just omit source during activation.

Related

"conda activate" is not redirecting python?

I have a conda env named py36 with python3.6 in it: (yea I know it is deprecated - there's a surprising amount of legacy code on older/unsupported versions..)
(py36) 11:34:52/py36 $conda env list
# conda environments:
#
base /Users/steve/opt/miniconda3
..
py36 * /Users/steve/opt/miniconda3/envs/py36
Let's double-check the python version:
(py36) 11:35:12/py36 $/Users/steve/opt/miniconda3/envs/py36/bin/python -V
Python 3.6.7 :: Anaconda, Inc.
Let's activate it:
$conda activate py36
(py36) $python -V
Python 3.9.12
So then why was the version unchanged? I searched for answers and discovered there is an open bug with conda PATH not set by conda activate . The main workaround - to include a package when creating the env - did not work. This is specifically what I tried
conda create -n py366 PYTHON=3.6 pip
$conda activate py366
$ (py366) $python -V
Python 3.9.12
Can anyone chime in on a workaround?
I see that there is an update to my $PATH in the .bash_profile below the section for conda_init() . Moving the $PATH modification before the conda_init() within the .bash_profile resolved this issue.

Azure Web app on Linux - Make Conda Installation persistent

I've been deploying a Node JS project that runs a Python script on Azure web app on Linux.
I've installed Conda in my /home/miniconda3 directory, but when I run the app it does recognizes neither the path nor the packages installed, like pandas or other. However, the installation is clearly present:
How can I make persistent the Conda installation?
Make sure you update the conda and install python:
conda update conda
conda install python=3.X
You can follow the below steps to activate the environment with few commands:
source activate environment-name
source conda activate environment-name
Below commands helped me in building conda environment:
#build the conda environment
ENV ENV_PREFIX $PWD/env
RUN conda update --name base --channel defaults conda && \
conda env create --prefix $ENV_PREFIX --file /tmp/environment.yml --force && \
conda clean --all --yes# run the postBuild script to install any JupyterLab extensions
RUN conda activate $ENV_PREFIX && \
/usr/local/bin/postBuild.sh && \
conda deactivate
You can have a look on the links mentioned by DeepDave.

How to remove anacnda environments that's not in default env directories?

I created an conda environment in the path of my choice rather than anaconda's default directory with:
~$ conda create --prefix=/data/sfy_envs/test python=3.8
After successed, the environments are visible in conda:
~$ conda info --envs
# conda environments:
#
base * /data/miniconda3
maskrcnn_sfy /data/miniconda3/envs/maskrcnn_sfy
torch16-sfy /data/miniconda3/envs/torch16-sfy
/data/sfy_envs/test
/data/sfy_envs/tf2-sfy
The last two environments are created with --prefix parameters, and have no name. I can activate them by directly refer to their path:
~$ conda activate /data/sfy_envs/test
But I cannot remove them. For example to remove test, I tried:
~$ conda remove /data/sfy_envs/test
Collecting package metadata (repodata.json): done
Solving environment: failed
PackagesNotFoundError: The following packages are missing from the target environment:
- /data/sfy_envs/test
and
~$ conda remove -p /data/sfy_envs/test
CondaValueError: no package names supplied,
try "conda remove -h" for more details
These won't work and I have on idea why.
Or could I just delete the environment directory manually, and remove their paths from the file .conda/environments.txt? I'm not sure if it's a safe treatment.
Use
conda env remove --prefix /data/sfy_envs/test
or
conda remove --prefix /data/sfy_envs/test --all

How to migrate anaconda envs to a new directory?

I have ssh access to a GPU cluster where I am taking over research from someone else. I wish to take the anaconda envs from /rhome/someoneelse/anaconda3/envs and move them to my installation of anaconda on /rhome/me/anaconda3. I have tried to directly copy the environment to the new directory but that didn't work. What is the way to copy the environment and have my anaconda installation work?
Use conda-pack
Install conda-pack
conda install -c conda-forge conda-pack
or
pip install conda-pack
Zipping other persons environment
While in the other machine and inside the other persons environment pack the environment and save to a tar file:
conda pack -n other_persons_environment -o environment_unpacked.tar.gz
Transfer the file environment_unpacked.tar.gz to your machine using scp or another tool.
Now to unzip the environment
mkdir -p new_directory_for_your_environment
tar -xzf environment_unpacked.tar.gz -C new_directory_for_your_environment
Unpacking
source new_directory_for_your_environment/bin/activate
python
conda-unpack
To your comment about running conda , you can see which conda is running by this command: which conda (to see the path from where conda is executing.)
Note - I misunderstood the question i.e. I though that the environment was on a different machine. It should be a lot easier if it is on the same machine. You would need to use the same steps with conda-pack and just omit the scp (other tool) file transfer part.

Conda: Creating a virtual environment

I'm trying to create a virtual environment. I've followed steps from both Conda and Medium.
Everything works fine until I need to source the new environment:
conda info -e
# conda environments:
#
base * /Users/fwrenn/anaconda3
test_env /Users/fwrenn/anaconda3/envs/test_env
source ~/anaconda3/bin/activate test_env
_CONDA_ROOT=/Users/fwrenn/anaconda3: Command not found.
Badly placed ()'s.
I can't figure out the problem. Searching on here has solutions that say adding lines to your bash_profile file, but I don't work in Bash, only C shell (csh). It looks like it's unable to build the directory path in activate.
My particulars:
OS X
Output of python --version:
Python 3.6.3 :: Anaconda custom (64-bit)
Output of conda --version:
conda 4.4.7
I am not sure what causes the problem in your case, but code below works for me without any issues (OS X, the same version of Conda as yours).
Creation of the environment
conda create -n test_env python=3.6.3 anaconda
Some explanation of the documentation of conda create is not clear:
-n test_env sets name of the environment to test_env
python=3.6.3 anaconda says that you want to use python in version 3.6.3 in this environment (exactly the one you have, and you can use a different one if you need it) and package anaconda. You can put all the things you need there, separated with spaces, e.g., sqlite matplotlib requests and specify their versions the same way as for python.
Activation
conda activate test_env
Deactivation
conda deactivate
Getting rid of it
conda remove -n test_env --all
Check if Conda is installed
conda -V
Check if Conda is up to date
conda update conda
Create a virtual environment
conda create -n yourenvname python=x.x anaconda
Activate your virtual environment
source activate yourenvname
Install additional Python packages to a virtual environment
conda install -n yourenvname [package]
Deactivate your virtual environment
source deactivate
Delete the virtual environment
conda remove -n yourenvname --all
I was able to solve my problem. Executing the source activate test_env command wasn't picking up my .bash_profile, and I normally work in tcsh. Simply starting a subprocess in Bash was enough to get activate working. I guess I assumed, incorrectly, that the activate command would start a child process in Bash and use Bash environment variables.
> conda info -e
> # conda environments:
> #
> base * ~/anaconda3
> test_env ~/anaconda3/envs/test_env
> bash
~$ source ~/anaconda3/bin/activate test_env
(test_env) ~$
(test_env) ~$ conda info -e
# conda environments:
#
test_env * ~/anaconda3/envs/test_env
root ~/anaconda3

Categories

Resources