How to clean up anaconda base environment? - python

I have just reinstalled Miniconda. After that I ran pip list in base environment. The output is following:
Package Version
---------------------- ---------
brotlipy 0.7.0
certifi 2021.10.8
cffi 1.15.0
charset-normalizer 2.0.4
colorama 0.4.4
conda 4.12.0
conda-content-trust 0+unknown
conda-package-handling 1.8.1
cryptography 36.0.0
idna 3.3
menuinst 1.4.18
pip 21.2.4
pycosat 0.6.3
pycparser 2.21
pyOpenSSL 22.0.0
PySocks 1.7.1
pywin32 302
requests 2.27.1
ruamel-yaml-conda 0.15.100
setuptools 61.2.0
six 1.16.0
tqdm 4.63.0
urllib3 1.26.8
wheel 0.37.1
win-inet-pton 1.1.0
wincertstore 0.2
But the fact is that I did not install them. How packages like tqdm, colorama, brotlipy, cryptography and others appeared here? It supposed to be an empty base environment. Your suggestions?

Do:
conda uninstall -n base --all

i would do:
conda clean -a -d
#-d = dryrun
and if that's okay with me
conda clean -a -y
#-y = yes (no promt)

Related

Pylint in Spyder is raising "E401 Unable to import" whithin conda environment

I am having some trouble with Spyder and pylint. I run Spyder in a conda environment by selecting the correct Python interpreter, and it works fine: I can import packages that are only installed in the environment. However, when I launch code analysis (F8), pylint complains that it cannot import them, with an error E0401: Unable to import 'package'. Pylint is installed in the conda environment.
Just as an example, flask is installed in my "web" environment but not in the base workspace. Import flask works fine in Spyder's console, but E0401 is raised by pylint.
Edit:
Spyder is NOT installed in the conda environment; following the "modular approach" described in Working with packages and environments in Spyder, I only installed spyder-kernels in the environment.
If I install spyder directly in the environment, the pylint problem disappears.
Edit 2: I created a new clean environment to test this problem. I am running windows 10, and here is the result of conda list:
astroid 2.4.2 py38_0
backcall 0.2.0 py_0
ca-certificates 2020.7.22 0
certifi 2020.6.20 py38_0
click 7.1.2 py_0
cloudpickle 1.6.0 py_0
colorama 0.4.3 py_0
decorator 4.4.2 py_0
flask 1.1.2 py_0
ipykernel 5.3.4 py38h5ca1d4c_0
ipython 7.18.1 py38h5ca1d4c_0
ipython_genutils 0.2.0 py38_0
isort 5.5.2 py38_0
itsdangerous 1.1.0 py_0
jedi 0.15.2 py38_0 conda-forge
jinja2 2.11.2 py_0
jupyter_client 6.1.6 py_0
jupyter_core 4.6.3 py38_0
lazy-object-proxy 1.4.3 py38he774522_0
libsodium 1.0.18 h62dcd97_0
markupsafe 1.1.1 py38he774522_0
mccabe 0.6.1 py38_1
openssl 1.1.1g he774522_1
parso 0.5.2 py_0
pickleshare 0.7.5 py38_1000
pip 20.2.2 py38_0
prompt-toolkit 3.0.7 py_0
pygments 2.7.1 py_0
pylint 2.6.0 py38_0
python 3.8.5 h5fd99cc_1
python-dateutil 2.8.1 py_0
pywin32 227 py38he774522_1
pyzmq 19.0.2 py38ha925a31_1
setuptools 49.6.0 py38_0
six 1.15.0 py_0
spyder-kernels 1.9.4 py38_0
sqlite 3.33.0 h2a8f88b_0
toml 0.10.1 py_0
tornado 6.0.4 py38he774522_1
traitlets 4.3.3 py38_0
vc 14.1 h0510ff6_4
vs2015_runtime 14.16.27012 hf0eaf9b_3
wcwidth 0.2.5 py_0
werkzeug 1.0.1 py_0
wheel 0.35.1 py_0
wincertstore 0.2 py38_0
wrapt 1.11.2 py38he774522_0
zeromq 4.3.2 ha925a31_3
zlib 1.2.11 h62dcd97_4
And pip list:
Package Version
astroid 2.4.2
backcall 0.2.0
certifi 2020.6.20
click 7.1.2
cloudpickle 1.6.0
colorama 0.4.3
decorator 4.4.2
Flask 1.1.2
ipykernel 5.3.4
ipython 7.18.1
ipython-genutils 0.2.0
isort 5.5.2
itsdangerous 1.1.0
jedi 0.15.2
Jinja2 2.11.2
jupyter-client 6.1.6
jupyter-core 4.6.3
lazy-object-proxy 1.4.3
MarkupSafe 1.1.1
mccabe 0.6.1
parso 0.5.2
pickleshare 0.7.5
pip 20.2.2
prompt-toolkit 3.0.7
Pygments 2.7.1
pylint 2.6.0
python-dateutil 2.8.1
pywin32 227
pyzmq 19.0.2
setuptools 49.6.0.post20200814
six 1.15.0
spyder-kernels 1.9.4
toml 0.10.1
tornado 6.0.4
traitlets 4.3.3
wcwidth 0.2.5
Werkzeug 1.0.1
wheel 0.35.1
wincertstore 0.2
wrapt 1.11.2
A few things I can suggest:
You should verify again that the Pylint installation is indeed associated with the Python interpreter. You can do so by running this command in the Terminal:
pip show pylint
then under Location verify the correct location of the package.
If you don't have terminal for Spyder, you can install it from here.
or download the package from Conda Terminal with:
conda install -c conda-forge spyder-terminal
or if it doesn't work maybe with this:
conda install spyder-terminal -c spyder-ide
If it does not show or seems right but still not working you can try to install pylint again running this command in the terminal:
pip install -U pylint
I saw a reoccurring problems with Spyder related to the F8 button. Verify that you indeed use the F8 button and not other methods. See this discussion for further insight
If all does not work for you, please provide more details about your Python version and operating system that might also be the cause of this linking problem.

pip does not install all of the packages if I ask it to do it just once

I have a fresh installation of python3 and python3-pip on Ubuntu.
I invoked the command:
pip3 install ansible packaging msrestazure docker-py ansible[azure] openshift
Then I invoked pip3 list. Here's the result:
root#7e8175337b62:/# pip3 list
Package Version
------------------- ---------
adal 1.2.4
ansible 2.9.11
cachetools 4.1.1
certifi 2020.6.20
cffi 1.14.1
chardet 3.0.4
cryptography 3.0
docker-py 1.10.6
docker-pycreds 0.4.0
google-auth 1.20.0
idna 2.10
isodate 0.6.0
Jinja2 2.11.2
kubernetes 11.0.0
MarkupSafe 1.1.1
msrest 0.6.18
msrestazure 0.6.4
oauthlib 3.1.0
openshift 0.11.2
packaging 20.4
pip 20.0.2
pyasn1 0.4.8
pyasn1-modules 0.2.8
pycparser 2.20
PyJWT 1.7.1
pyparsing 2.4.7
python-dateutil 2.8.1
python-string-utils 1.0.0
PyYAML 5.3.1
requests 2.24.0
requests-oauthlib 1.3.0
rsa 4.6
ruamel.yaml 0.16.10
ruamel.yaml.clib 0.2.0
setuptools 45.2.0
six 1.15.0
urllib3 1.25.10
websocket-client 0.57.0
wheel 0.34.2
I saw that not all of the azure packages got installed. So, I run pip3 install ansible[azure] this time, although I already asked pip to install that package. After installation finishes, this is the result of pip3 list:
root#7e8175337b62:/# pip3 list
Package Version
------------------------------ ---------
adal 1.2.4
ansible 2.9.11
applicationinsights 0.11.9
argcomplete 1.12.0
azure-cli-core 2.0.35
azure-cli-nspkg 3.0.2
azure-common 1.1.11
azure-graphrbac 0.40.0
azure-keyvault 1.0.0a1
azure-mgmt-authorization 0.51.1
azure-mgmt-automation 0.1.1
azure-mgmt-batch 5.0.1
azure-mgmt-cdn 3.0.0
azure-mgmt-compute 4.4.0
azure-mgmt-containerinstance 1.4.0
azure-mgmt-containerregistry 2.0.0
azure-mgmt-containerservice 4.4.0
azure-mgmt-cosmosdb 0.5.2
azure-mgmt-devtestlabs 3.0.0
azure-mgmt-dns 2.1.0
azure-mgmt-hdinsight 0.1.0
azure-mgmt-iothub 0.7.0
azure-mgmt-keyvault 1.1.0
azure-mgmt-loganalytics 0.2.0
azure-mgmt-marketplaceordering 0.1.0
azure-mgmt-monitor 0.5.2
azure-mgmt-network 2.3.0
azure-mgmt-nspkg 2.0.0
azure-mgmt-rdbms 1.4.1
azure-mgmt-redis 5.0.0
azure-mgmt-resource 2.1.0
azure-mgmt-servicebus 0.5.3
azure-mgmt-sql 0.10.0
azure-mgmt-storage 3.1.0
azure-mgmt-trafficmanager 0.50.0
azure-mgmt-web 0.41.0
azure-nspkg 2.0.0
azure-storage 0.35.1
bcrypt 3.1.7
cachetools 4.1.1
certifi 2020.6.20
cffi 1.14.1
chardet 3.0.4
colorama 0.4.3
cryptography 3.0
docker-py 1.10.6
docker-pycreds 0.4.0
google-auth 1.20.0
humanfriendly 8.2
idna 2.10
isodate 0.6.0
Jinja2 2.11.2
jmespath 0.10.0
knack 0.3.3
kubernetes 11.0.0
MarkupSafe 1.1.1
msrest 0.6.1
msrestazure 0.5.0
oauthlib 3.1.0
openshift 0.11.2
packaging 20.4
paramiko 2.7.1
pip 20.0.2
pyasn1 0.4.8
pyasn1-modules 0.2.8
pycparser 2.20
Pygments 2.6.1
PyJWT 1.7.1
PyNaCl 1.4.0
pyOpenSSL 19.1.0
pyparsing 2.4.7
python-dateutil 2.8.1
python-string-utils 1.0.0
PyYAML 5.3.1
requests 2.24.0
requests-oauthlib 1.3.0
rsa 4.6
ruamel.yaml 0.16.10
ruamel.yaml.clib 0.2.0
setuptools 45.2.0
six 1.15.0
tabulate 0.8.2
urllib3 1.25.10
websocket-client 0.57.0
wheel 0.30.0
xmltodict 0.12.0
As you can see, the second time I requested the installation of ansible[azure] it actually installed all the packages. Why didn't it work the first time I asked?
1- pip3 install packaging ansible msrestazure docker-py ansible[azure] openshift
2- pip3 install packaging msrestazure docker-py ansible[azure] openshift
Why the first one install all the azure packages? but the second is just only installing ansible?
The reason is, when ansible[azure] is executed, pip checks whether the ansible package is installed or not. The ansible package is installed in the first place (pip3 install ansible). Therefore the time we execute pip3 install ansible[azure], pip thought all the necessary packages were installed. Therefore skips the remaining and the crucial azure packages.
Since this is a long explanation I couldn't fit into the comment section. Therefore, I wrote as an answer.

robot: command not found in Mac

I installed python3 and robot framework from command line. When I run robot test cases. I keep getting an error, "robot: command not found". Below is pip list and pip3 list.
Sindoo:~ XXXXXXXXX$ pip list
Package Version
------------------------------ ----------
appdirs 1.4.3
certifi 2020.4.5.1
distlib 0.3.0
filelock 3.0.12
importlib-metadata 1.6.0
pip 20.1
pipenv 2018.11.26
robotframework 3.2
robotframework-seleniumlibrary 3.3.1
selenium 3.141.0
setuptools 46.1.3
six 1.14.0
urllib3 1.25.9
virtualenv 20.0.20
virtualenv-clone 0.5.4
wheel 0.34.2
zipp 3.1.0
Sindoo:~ XXXXXXXXX$ pip3 list
Package Version
------------------------------ ----------
appdirs 1.4.3
certifi 2020.4.5.1
distlib 0.3.0
filelock 3.0.12
importlib-metadata 1.6.0
pip 20.1
pipenv 2018.11.26
robotframework 3.2
robotframework-seleniumlibrary 3.3.1
selenium 3.141.0
setuptools 46.1.3
six 1.14.0
urllib3 1.25.9
virtualenv 20.0.20
virtualenv-clone 0.5.4
wheel 0.34.2
zipp 3.1.0
When I try to check robot --version. I get an error.
robot --version
-bash: robot: command not found
May I know Why robot is not working?
Try running python -m robot or python3 -m robot instead.

How to deal with new pip3.x for each Python version

After recently upgrading from python 3.7 to 3.8, I realized that my packages installed on my system were not transferred over after installing 3.8. Specifically, I am seeing the below for pip3.7 list:
Package Version
----------------- ---------
appdirs 1.4.3
astroid 2.3.3
attrs 19.3.0
click 7.1.1
isort 4.3.21
lazy-object-proxy 1.4.3
mccabe 0.6.1
pathspec 0.7.0
pip 20.0.2
pylint 2.4.4
regex 2020.2.20
setuptools 46.0.0
six 1.14.0
toml 0.10.0
typed-ast 1.4.1
wheel 0.34.2
wrapt 1.11.2
while pip3 or pip3.8 list shows:
Package Version
---------- -------
pip 20.0.2
setuptools 41.2.0
Is this the expected behavior or did not do something wrong while upgrading to 3.8? If this is the expected behavior, how do you transfer the packages over to the new version? Is it not best practice to do so?

Can't install any pip package within my docker environment, since it won't be recognized

I am running a Cookiecutter django project in a docker environment and I would like to add new packages via pip. Specifically I want to add: djangorestframework-jwt
When I do:
docker-compose -f local.yml run --rm django pip install
it seems like it would be perfectly working because I get:
Successfully installed PyJWT-1.7.1 djangorestframework-jwt-1.11.0
Now the problem is that it doesn't install it. It doesn't appear when I run pip freeze, and also not in pip list
Then I tried to put it into my requirements.txt file and run it with:
docker-compose -f local.yml run --rm django pip install -r requirements/base.txt
Same result. It says that it is successfully installed but it is not. I thought it might be a problem with my django version and the package, but the same happens when I try to update my pip. It says it updated, but when I run pip install -upgrade pip I get again:
You should consider upgrading via the 'pip install --upgrade pip' command.
I'm running out of options.
My requirements:
-r ./base.txt
Werkzeug==0.14.1 # https://github.com/pallets/werkzeug
ipdb==0.11 # https://github.com/gotcha/ipdb
Sphinx==1.7.5 # https://github.com/sphinx-doc/sphinx
psycopg2==2.7.4 --no-binary psycopg2 # https://github.com/psycopg/psycopg2
# Testing
# ------------------------------------------------------------------------------
pytest==3.6.3 # https://github.com/pytest-dev/pytest
pytest-sugar==0.9.1 # https://github.com/Frozenball/pytest-sugar
# Code quality
# ------------------------------------------------------------------------------
flake8==3.5.0 # https://github.com/PyCQA/flake8
coverage==4.5.1 # https://github.com/nedbat/coveragepy
# Django
# ------------------------------------------------------------------------------
factory-boy==2.11.1 # https://github.com/FactoryBoy/factory_boy
django-debug-toolbar==1.9.1 # https://github.com/jazzband/django-debug-toolbar
django-extensions==2.0.7 # https://github.com/django-extensions/django-extensions
django-coverage-plugin==1.5.0 # https://github.com/nedbat/django_coverage_plugin
pytest-django==3.3.2 # https://github.com/pytest-dev/pytest-django
djangorestframework-jwt==1.11.0 # https://github.com/GetBlimp/django-rest-framework-jwt
Output of pip list:
Package Version
------------------------ --------
alabaster 0.7.12
argon2-cffi 18.1.0
atomicwrites 1.3.0
attrs 19.1.0
Babel 2.6.0
backcall 0.1.0
certifi 2019.3.9
cffi 1.12.2
chardet 3.0.4
coreapi 2.3.3
coreschema 0.0.4
coverage 4.5.1
decorator 4.4.0
defusedxml 0.5.0
Django 2.0.7
django-allauth 0.36.0
django-coverage-plugin 1.5.0
django-crispy-forms 1.7.2
django-debug-toolbar 1.9.1
django-environ 0.4.5
django-extensions 2.0.7
django-model-utils 3.1.2
django-redis 4.9.0
django-widget-tweaks 1.4.3
djangorestframework 3.8.2
docutils 0.14
factory-boy 2.11.1
Faker 1.0.4
flake8 3.5.0
idna 2.8
imagesize 1.1.0
ipdb 0.11
ipython 7.4.0
ipython-genutils 0.2.0
itypes 1.1.0
jedi 0.13.3
Jinja2 2.10
MarkupSafe 1.1.1
mccabe 0.6.1
more-itertools 6.0.0
oauthlib 3.0.1
packaging 19.0
parso 0.3.4
pexpect 4.6.0
pickleshare 0.7.5
Pillow 5.2.0
pip 19.0.3
pluggy 0.6.0
prompt-toolkit 2.0.9
psycopg2 2.7.4
ptyprocess 0.6.0
py 1.8.0
pycodestyle 2.3.1
pycparser 2.19
pyflakes 1.6.0
Pygments 2.3.1
pyparsing 2.3.1
pytest 3.6.3
pytest-django 3.3.2
pytest-sugar 0.9.1
python-dateutil 2.8.0
python-slugify 1.2.5
python3-openid 3.1.0
pytz 2018.5
redis 3.2.1
requests 2.21.0
requests-oauthlib 1.2.0
setuptools 40.8.0
six 1.12.0
snowballstemmer 1.2.1
Sphinx 1.7.5
sphinxcontrib-websupport 1.1.0
sqlparse 0.3.0
termcolor 1.1.0
text-unidecode 1.2
traitlets 4.3.2
Unidecode 1.0.23
uritemplate 3.0.0
urllib3 1.24.1
wcwidth 0.1.7
Werkzeug 0.14.1
wheel 0.33.1
Any help is highly appreciated! Thanks...
docker-compose run starts a new container and executes the command in it. When used with --rm flag the container gets removed after command completes.
What happens is you get a new container created, and packages installed, or pip upgraded, inside this container. Once the command completes the container is removed.
If later on you run something like docker-compose -f local.yml run --rm pip list a brand new container will get created and pip list executed inside it, showing no packages from previous run since they were installed in a different container, which is already removed.
A better way would be to create docker image that includes your application and install pip packages during docker build. You can check a sample in this question
This way any time you start a container from your image it will have all packages inside.

Categories