I am on a Windows machine running WSL2 with Ubuntu 22.04 (fresh install) afterwards I installed Anaconda with wget https://repo.anaconda.com/archive/Anaconda3-5.1.0-Linux-x86_64.sh and bash Anaconda3-5.1.0-Linux-x86_64.sh. I also update my conda by running conda update conda
However when I create a new conda enviroment (conda create --name=test-env python=3.8) and activate my test-env environment to install pip (conda install pip), so I can install packages with pip, all package I install with pip are installed into the base anaconda environment.
f which -a pip returns /home/user/anaconda3/bin/pip I've tried adding /home/user/anaconda3/envs/test-env/lib/python3.8/site-packages to my $PATH variable by executing export PATH=/home/user/anaconda3/envs/test-env/lib/python3.8/site-packages:$PATH and executing source ~/.bashrc but this doesn't even change anything to the result of which -a pip (pip installed in my environment is not added), so it still installs my pip packages inside base instead of my environment.
How do I get ubuntu wsl2 to run the correct pip package manager when I activate my environment? Some goes for python, if I run python when my environment is active it references python that is installed in base and not my active environment
Related
I'm trying to build PyTorch from a .whl file on a jetson nano.
I am able to build and install the file but only while using sudo, attempting to pip install the file without sudo results in this error:
ERROR: torch-1.10.0a0+git36449ea-cp36-cp36m-linux_aarch64.whl is not a supported wheel on this platform.
This is strange as with admin I have no issues installing this file, but I can then only use the library by using the sudo command before going into or running with the python command.
I should note that this is in a conda environment, but even in the base conda environment this issue still occurs.
It seems like I can also install the package by using conda deactivate to deactivate conda.
I am using Python 3.7 in the conda environment and Python 3.6 outside.
I am using Python 3.7 in the conda environment and Python 3.6 outside.
This is the issue. You have a cp36 whl file, so python 3.6. I am suspecting that when you run sudo pip, your systems pip is invoked, whereas when you run pip, then pip from your conda env is used, and cannot install a python 3.6 whl to a python 3.7 env.
Either you need to get the cp37 whl or create a conda env that has python 3.6 installed
Checked the conda environment using the below command:
> conda info
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.
If you had a working version of a conda environment before this error started to occur, you can revert back to that working environment using this command:
conda list --revision
and
conda install --revision [n]
Otherwise, you can try to [re]install conda from the miniconda install web page:
I've installed Anaconda on linux, it's installed in user space under my home folder.
I've created an environment.
Within that environment I've run conda install anaconda to install all standard packages.
I'm trying to install tensorflow now, running:
pip install --upgrade tensorflow-gpu
This process attempts to upgrade the numpy package. But that step errors out because it's trying to uninstall the system numpy package in /usr/local/bin/f2py.
I thought this environment was all self-contained in user space. Any idea why it would attempt to uninstall a system package that was installed before Anaconda was installed?
You probably need to clear your PYTHONPATH environment variable, if its pointing at the system installation of Python.
I am using conda(anaconda 2). Before installing anaconda, my Ubuntu16.04 already had pip installed. I recently installed virtualenv using pip install virtualenv. I did the following steps while trying to install coala in my virtual environment.
Create a new virtual environment using virtualenv venv
Activate environment using source activate path/to/activate
Clone the coala repository.
Run pip3 install -e . while inside the repository
After all this, I get the following error from coala:
There is a conflict in the version of a dependency you have installed and the requirements of coala. This may be resolved by creating a separate virtual environment for coala or running `pip install "yapf~=0.14.0"`. Be aware that the latter solution might break other python packages that depend on the currently installed version.
I am already in a virtualenv, so I tried installing yapf as per the command: pip install "yapf~=0.14.0". After that, when I check my pip list, it still showed yapf (0.15.2), To solve this, I did:
pip uninstall yapf
pip install "yapf~=0.14.0"
Now when I check my pip list, I get the desired results. BUT, the error is still there. It still shows the same dependency error. I am unable to understand what is happening? Which pip is installing what and where, what is conda doing behind the scenes, how is virtualenv behaving with conda, and the most important, why this error and how to resolve it?
first create a virtualenv pertaining to python3.x
template
virtualenv -p {location of python3 version } {name of virtualenv folder}
like this
virtualenv -p /usr/local/bin/python3 venv
then activate it
source venv/bin/activate
then run
pip install {library you want to use}
pip install "yapf~=0.14.0"
This should install yapf into the venv folder.
try that let us know.
Answering my own question, what I found out was that conda and virtualenv do not go hand in hand. condas has the ability to create it's own virtual environment, and if using condas, we must create a conda virtual environment(See this answer).
What I did was uninstalled conda and make a virtual environment using virtualenv. What I could have done as well is uninstall virtualenv and create condas environment and work in that.
How can I add a package to an existing conda environment?
If it is a python package I can use pip install <package>, but what if pip does not work?
Is it sufficient to activate the environment and use conda install <package>?
You've answered your own question. In fact you really want to do conda install ... instead of using pip if you can.
You can install a conda package also without activating the environment. Just use conda install -n <env_name> <package> or conda install -p <path/to/env> <package>.
If you want to install a specific package inside a specific conda environment, you can use the following command.
First activate the conda environment and then do:
$ conda install --name <conda_env_name> -c <channel_name> <package_name>
For a concrete example, let's assume that you want to install chainer from the channel anaconda to an already created conda environment named chainerenv, then you can do:
$ conda install --name chainerenv -c anaconda chainer
If you want to install a package in the environment, you can use
conda install -p /path/to/env package
example:
conda install -p /users/dekstop/env-test Django
There's an alternative way to do this and I have just tested it on my own mac:
example: i want to install a non-conda package at my python2.7 environment:
go to terminal
activate the desired environment by: source activate py27
after you successfully activated the environment, you can install the package you wanted by: pip install package
The answer is yes (usually).
One example is that you can activate your conda environment and then directly do conda install pandas.tar.bz2 on the existing tar.bz2 files from /conda_envs/.pkgs (leftovers from other environments)
If you don't have a tarball package like that but you have the src with setup.py you can just do the usual install by python setup.py install (or python setup.py develop to link the src)