Installing a package inside Conda using apt install - python

I'm trying to install opencv in my Jetson TX2. I would like to install it within my conda environment. I used the following command to do so,
sudo apt-get install python-opencv
It actually installs opencv but outside the conda so I'm not able to import it within conda. How can I have it installed within my conda?.

apt install for system-wide package install
conda install for installing package in conda environment

Make sure you are in a conda environment.
Run a conda command, instead of an apt-get command.
conda install -c conda-forge opencv

You can just install pip in the conda environment and install opencv using pip.
conda install pip
pip install opencv-python

Related

Trying to download ipykernel onto my virtual environment (Windows)

I am trying to install ipykernel onto my virtual venv enrioment on windows. I typed python -m pip install ipykernel but I get the following error:
ERROR: Could not build wheels for psutil, pyzmq, which is required to install pyproject.toml-based projects
I tried downgrading using the command pip install pip==21.3.1 but I did not find any luck downloading pip onto my venv afterward either. I also tried using the command python -m pip install ipykernel which also did not work.
Let me know if you have any other ideas!
Try installing from source
git clone
cd ipykernel
pip install -e ".[test]"

Force uninstall of the package pip

I'm sorry if this is a repeat question, but whenever I search force uninstall of pip I get something like a pip uninstall command. What I want is a way to uninstall the package pip (and reinstall). when I run python3 -m pip uninstall pip setuptools in a conda enviroment I get this error:
Not uninstalling pip at /usr/lib/python3/dist-packages, outside environment /usr
Can't uninstall 'pip'. No files were found to uninstall.
Found existing installation: setuptools 45.2.0
Not uninstalling setuptools at /usr/lib/python3/dist-packages, outside environment /usr
Can't uninstall 'setuptools'. No files were found to uninstall.
I also get the same error in the base enviroment when I run /usr/lib/python3 -m pip uninstall pip setuptools.
However when I'm outside of a virtual enviroment (base) and I just run python3 -m pip uninstall pip setuptools, I get:
/home/cameron/anaconda3/bin/python3: No module named pip
I could just remove the file but I want to avoid if that would be problematic.
The problematic thing is I can still install things with pip in my base enviroment but I can't call python programs in my virtual enviroments anymore nor install new ones with pip (perhaps able to with conda) since it defaults to the packages installed with this pip even in a venv.
this should remove pip from your active conda environment
conda uninstall pip --force
I was finally able to remove with sudo apt-get purge python3-pip

How to install pip library in ec2-instance virtual environment using user data?

enter image description hereI am try to install pip libraries in ec2-instances virtual environment using user data.
But while I am trying that I will create at instance level but not at virtual environment level.
What I need exactly is will I am creating ec2-instance on configuration level I want to define that to create pip libraries at virtual environment level.
#!/usr/bin/env bash
sudo yum update
sudo yum install python3 pip3 -y
sudo pip3 install --upgrade pip
pip install --upgrade pip
python3 -m venv /home/ec2-user/vertual-Environment
pip install django
pip install djangorestframework
pip install pillow
You have to source your python env envrionment.
Example (I have verified now the code on Amazon Linux 2):
#!/usr/bin/env bash
sudo yum update -y
sudo yum install python3 python3-pip -y
sudo pip3 install --upgrade pip
pip install --upgrade pip
python3 -m venv /home/ec2-user/vertual-Environment
# source your new python env
source /home/ec2-user/vertual-Environment/bin/activate
pip install django
pip install djangorestframework
pip install pillow
Using user data, your should install your dependencies this way :
python3 -m venv /home/ec2-user/vertual-Environment
/home/ec2-user/vertual-Environment/bin/pip install django
/home/ec2-user/vertual-Environment/bin/pip install djangorestframework
/home/ec2-user/vertual-Environment/bin/pip install pillow
When using userdata, your script are executed independently, regardless of what have been done in previous executions.

pip install package with --user and without --user, now I want to uninstall package installed without --user

First, I run
pip install virtualenv
and later, I run
pip install --user virtualenv
So, this is what I have now
$ which -a virtualenv
/Users/admin/.local/bin/virtualenv
/usr/local/bin/virtualenv
This is my default virtualenv
/Users/admin/.local/bin/virtualenv
Now I want to uninstall, this,
/usr/local/bin/virtualenv
What should I do?
Thanks!
I tried
pip uninstall virtualenv
It removed /usr/local/bin/virtualenv, the system wide package.
The package I installed using --user flag, which cannot be uninstalled.
I just manually removed the folder.
See this thread.
How to uninstall a package installed with pip install --user

Can't pip install packages in Anaconda

I broke conda somehow by updating it. If there was a package pack that I couldn't get using
conda install pack
I could do
pip install pack
and everything worked great. That package would then be accessible from the python in anaconda/bin/python.
After running conda update conda, pip corresponds not to the conda environment but to the base python on osx (I think).
which pip
/usr/local/bin/pip
I tried navigating to the pip package in the anaconda folder. But even running
pip install pack
from there installs the package in /Library/Python/2.7/site-packages and not in //anaconda. Any ideas on how to fix this? Thanks!
Edited:
which conda
/Users/Ben/anaconda/bin/conda
echo$PATH
bash:echo/Users/Ben/anaconda/bin:/Library/Frameworks/Python.framework/Versions/3.4/bin:/Library/Frameworks/Python.framework/Versions/3.4/bin://anaconda/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/Ben/anaconda/bin:/opt/X11/bin:/usr/texbin: No such file or directory
Try conda update pip or conda update -f pip to force it.
You should get rid of the original OS python pip, use:
With Debian/Ubuntu:
sudo apt-get purge python-pip
With Redhat/Centos/Fedora:
sudo yum remove python-pip
That was referenced here: https://unix.stackexchange.com/questions/187701/how-do-i-correct-the-path-for-pip

Categories