Currently I have installed a software called ArcGIS Pro 2.1 in C:\Program Files and it comes with a conda that is the only python I have on this computer. Now I need python for other projects and I don't want to go through IT department every time I need to install some python packages because I don't have the admin right.
Will installing another conda in a folder that I have right to edit mess up anything of the ArcGIS conda?
Or can I use the ArcGIS conda to create another python environment outside C:\Program Files in a folder I have right to edit?
Thanks.
You should be able to leverage the existing conda. You just need to make sure you always use the --prefix command to actually write the environment folder into a directory you can write to.
Check out the conda-create help docs. Look at the --prefix option
-- Edit --
There's actually an existing thread discussion about it. Check out this other SO link how to specify new environment location for conda create
Related
I need to create new virtual environment in PyCharm. There are already some files in the folder.
This is how my project looks like:
I want to create venv in heureka-negativni-reviews
I try: File -> New project.
I switch this settings:
to have Python 3.10 as an interpreter and to create venv in heureka-negativni-reviews
But when I click on create, I got:
EDIT:
I found that I am not able to select Python 3.10 as an interpreter:
But I cannot click OK when I select Python 3.10:
What is the problem, please?
Now we see the reason, why your IDE is not able to create your venv, since the command line isn't either, which is the set of commands your IDE typically uses.
The pip and pip3 belongs to python3.8 and that is another problem, if you want to install python packages for python 3.10, which isn't possible this time without system invention.
Also your python setup seems to be messed.
/home/vojta/Desktop/INTERNET_HANDEL/HEUREKA/heureka-negativni-reviews/venv/bin/python
seems not to be a general system path. It looks that you built your own version of python and installed it by a specific prefix. Installing python correctly is off the topic here.
There are different installers for different platforms which provide install instruction inside their archives.
Before doing this, it's recommended to clean up your messed installation first.
You may find information here and there.
It could also be, that you are trying to create another venv from within an already sourced venv. Such kind of composed venvs can lead to confusion and that would explain your path above a bit more, which contains /venv/.
Also manually remove all your custom python versions from your /home/vojta/ directory, like $ rm -r /home/vojta/Desktop/INTERNET_HANDEL
First ensure that the Python interpreter is added to the list available (by adding as an 'Existing environment').
Then add a venv via link
Then drag and drop your existing files to the venv directory.
before with venv after drag and drop
I'm wondering how to go about installing Anaconda miniconda in a particular location on my system.
If I have some project
~/some-project
That I want to use conda for, but don't want to use conda anywhere else on my system, how do I go about that?
Ideally there will be some approach where I can do
cd ~/some-project
install miniconda here only as some-project-env
And I can then, within ~/some-project, activate some-project-env. This solution will not touch any rc configuration files, all configuration settings for some-project-env will be contained within ~/some-project.
So, if I was to only create some-project-env, and then deleted ~/some-project, there would be no trace of conda on my system.
Edit
It would still be of interest to have a solution to this post. Something that might be of use to someone finding this is the following in their ~/.condarc
auto_activate_base: false
I have updated the anaconda packages for the python program I was working on. I now want to install these new packages on computers that are offline.
I have generated a list of the installed packages using the following command:
>conda list -e > packagelist.txt
I want to be able to update the packages on the offline computers using something like this:
>conda install --file (location of 'packagelist') --channel file://(location of the folder where the packages are located)
So my question is: how do I easily make a folder, "pkgs", that contains all the package files indicated in my package list?
Can I simply just use the entire "pkgs" folder that is located in my current Anaconda installation location ? Or are the packages in my package list not necessarily installed inside there?
I apologize if the question is 'nooby', I honestly don't know how to. Looking forward to any help.
If anyone else is struggling with this, these are the steps I took:
Create a file containing the names of all the packages installed in the current environment. One way to do this(already shown in question) is by typing the following on a command prompt (run as admin):
conda list -e > packagelist.txt
Go to the "pkgs" folder that is located in your Anaconda installation directory. Copy all the zipped packages there (only the ones that have a ".tar.bz2" file extension), and paste them inside another folder somewhere, lets call it "pkgs2".
Compare the packages in the "packagelist" text file you created with the packages inside the the new folder you created, "pkgs2". Delete older package versions.For example, there might be two different numpy versions in your "pkgs2" folder. Delete the outdated one if necessarily.
Create index and repodata files. I'm not entirely sure why. The important one is the "repodata.json.bz2" file. You can create this by typing the following in command prompt (obviously your "pkgs2" might be located somewhere else, so adjust accordingly):
conda index C:\Users\myName\Desktop\pkgs2
If you get the following error:
Indexing a copy of the Anaconda conda package channel is neither
necessary nor supported. If you which to add your own packages,
you can do so by adding them to a separate channel.
then you have to go to your "pkgs2" folder and delete the "_license" package.I don't know why it works but it does (saw the solution to the error from a google search).
You should see that 3 new files were added to the "pkgs2" folder after the indexing was completed. They are called ".index.json", "repodata.json" and "repodata.json.bz2".
You can now transfer the "pkgs2" folder and the "packagelist.txt" to another computer. You can also include a setup file for installing anaconda if the computer doesn't already have it installed. To install the new/updated packages offline, enter the following in a command prompt on the offline computer that has anaconda installed (once again, obliviously adjust the file names and locations accordingly) :
conda install --file C:\Users\myName\Desktop\OfflineInstall\packagelist.txt --channel file://C:\Users\myName\Desktop\OfflineInstall\pkgs2
If all went well, you should see something like this in your command prompt:
. And once the new packages are installed, you are done!
You might however, run into the following problem during Step 5 (this is just an example):
UnsatisfiableError: The following specifications were found to be in conflict:
- matplotlib 1.4.3 np19py27_1 -> pyparsing 2.0.3
- pyparsing 2.2.0 py27_0
Use "conda info <package>" to see the dependencies for each package.
Adjust your packages accordingly, either deleting conflicting ones you don't need, or updating the ones shown. Repeat from Step 4 and you should be ok at the end.
Hope this helps someone !
I have Anaconda for Python 2, It came packed with a lot of useful packages. During my work, I have added several packages to it using conda install command. Now I have to format my system, and I want to backup/pack all the added libraries, either as full packages or even by knowing the installation command of each one.
I searched StackOverflow, I found one unanswered question with a similar problem, the question suggested conda list -e >file_list.txt to create a file contains all the installed packages, but this is not sufficient for me, I want Anaconda to determine which package is added by me, and by which command, or to pack the added packages in full.
Thanks for help.
I think you can find the solution you are looking for here.
Open the Anaconda prompt
Activate the environment you are interested in
Type conda env export > environment.yml
In the yml you will find all the dependencies and you can use it to create a new virtual environment as a copy of the current one.
For example, on the new/rebooted machine, you can do:
conda env create -f environment.yml
I know how to install packages in Anaconda using conda install and also how to install packages that are on PyPi which is described in the manual.
But how can I permanently include packages/folders into the PYTHONPATH of an Anaconda environment so that code that I am currently working on can be imported and is still available after a reboot?
My current approach is to use sys:
import sys
sys.path.append(r'/path/to/my/package')
which is not really convenient.
Any hints?
I found two answers to my question in the Anaconda forum:
1.) Put the modules into into site-packages, i.e. the directory $HOME/path/to/anaconda/lib/pythonX.X/site-packages which is always on sys.path. This should also work by creating a symbolic link.
2.) Add a .pth file to the directory $HOME/path/to/anaconda/lib/pythonX.X/site-packages. This can be named anything (it just must end with .pth). A .pth file is just a newline-separated listing of the full path-names of directories that will be added to your path on Python startup.
Alternatively, if you only want to link to a particular conda environment then add the .pth file to ~/anaconda3/envs/{NAME_OF_ENVIRONMENT}/lib/pythonX.X/site-packages/
Both work straightforward and I went for the second option as it is more flexible.
*** UPDATE:
3.) Use conda develop i. e. conda-develop /path/to/module/ to add the module which creates a .pth file as described under option 2.).
4.) Create a setup.py in the folder of your package and install it using pip install -e /path/to/package which is the cleanest option from my point of view because you can also see all installations using pip list. Note that the option -e allows to edit the package code. See here for more information.
Thanks anyway!
I'm able to include local modules using the following:
conda-develop /path/to/module/
I hope it helps.
The way I do this, which I believe is the most native to conda, is by creating env_vars.sh files in my environment, as per the official documentation here.
For macOS and Linux users, the steps are as follows:
Go to your environment folder (e.g. /miniconda1/env/env_name). $CONDA_PREFIX is the environemnt variable for your environment path.
cd $CONDA_PREFIX
Create the activate.d and deactivate.d directories.
mkdir -p ./etc/conda/activate.d
mkdir -p ./etc/conda/deactivate.d
Inside the each respective directory, create one env_vars.sh file. The one in the activate.d directory will set (or export) your environment variables when you conda activate your environment. The file in the deactivate.d directory will serve to unset the environment variables when you conda deactivate your environment.
touch ./etc/conda/activate.d/env_vars.sh
touch ./etc/conda/deactivate.d/env_vars.sh
First edit the $CONDA_PREFIX/etc/conda/activate.d/env_vars.sh to export the desired environment variables.
#!/bin/sh
export VAR_A='some-thing-here'
export VAR_B=/path/to/my/file/
Afterwards, open to edit the $CONDA_PREFIX/etc/conda/deactivate/env_vars.sh, in order to unset the env variables when you conda deactivate like so:
#!/bin/sh
unset VAR_A
unset VAR_B
Again, the source of my description comes straight from the conda docs here.
Just to add to Cord Kaldemeyer's answer above, for the 2nd option. If you only want to link to a particular conda environment then add the .pth file to ~/anaconda3/envs/{NAME_OF_ENVIRONMENT}/lib/pythonX.X/site-packages/