`pip3 list` showing uninstalled package - python

Last week I installed awscli with pip3, and today I decided to uninstall it. The uninstall was successful, but pip3 list gives me the following output:
~
❯ pip3 list
Package Version
----------------- ----------
- scli
-wscli 1.16.137
astroid 2.0.4
botocore 1.12.127
certifi 2018.10.15
colorama 0.3.9
docutils 0.14
isort 4.3.4
jmespath 0.9.4
lazy-object-proxy 1.3.1
mccabe 0.6.1
pip 19.0.3
pyasn1 0.4.5
pylint 2.1.1
python-dateutil 2.8.0
PyYAML 3.13
rsa 3.4.2
s3transfer 0.2.0
setuptools 40.8.0
six 1.11.0
urllib3 1.24.1
virtualenv 16.1.0
virtualenv-clone 0.4.0
wheel 0.33.1
wrapt 1.10.11
The top two entries appear to be related to awscli. Even the version number (1.16.137) is the same as awscli's. Anyone know how to resolve this issue?
EDIT:
Found this:
/usr/local/lib/python3.7/site-packages
❯ ls
__pycache__ mccabe-0.6.1.dist-info virtualenv.py
astroid mccabe.py virtualenv_clone-0.4.0.dist-info
astroid-2.0.4.dist-info pip virtualenv_support
botocore pip-19.0.3-py3.7.egg-info wheel
botocore-1.12.130.dist-info pkg_resources wheel-0.32.2-py3.7.egg-info
certifi pylint wheel-0.33.0-py3.7.egg-info
certifi-2018.10.15.dist-info pylint-2.1.1.dist-info wheel-0.33.1-py3.7.egg-info
clonevirtualenv.py setuptools wrapt
easy_install.py setuptools-40.8.0-py3.7.egg-info wrapt-1.10.11.dist-info
isort sitecustomize.py ~-scli-1.16.137.dist-info
isort-4.3.4.dist-info six-1.11.0.dist-info ~wscli-1.16.137.dist-info
lazy_object_proxy six.py
lazy_object_proxy-1.3.1.dist-info virtualenv-16.1.0.dist-info
Safe to delete the two offending directories?

pip list takes this information from .dist-info entries in your path. You appear to have some extra names there, given your listing. Note the two entries at the end:
~-scli-1.16.137.dist-info
~wscli-1.16.137.dist-info
Simply delete these two directory entries.
Note that awscli did not create these directories, especially because pip would have used the universal wheel file to install awscli, so no setup script needed to be run when it was installed. They remind me of the Windows hidden lock files (which start with ~$), so perhaps they were created when you used another tool I'm not familiar with that may have accidentally left these lying around.
It doesn't really matter if those .dist-info entries are directories, symlinks, or files, all that pip list does is take all names that end in .dist-info then splits out version and name at the first -. You can create any phantom entry just by creating empty files:
$ mkdir demo && cd demo && virtualenv-3.8 .
# ....
$ bin/pip list # new, empty virtualenv
Package Version
---------- -------
pip 19.0.3
setuptools 41.0.0
wheel 0.33.1
$ touch lib/python3.8/site-packages/foobar-version.dist-info
$ bin/pip list # surprise package listed
Package Version
---------- -------
foobar version
pip 19.0.3
setuptools 41.0.0
wheel 0.33.1

Related

No module named 'social_django' but 'social-auth-app-django' is installed

Summary of Issue
I am creating a Django project and attempting to setup Auth0 integrations. Per Auth0's documentation, I installed the social-auth-app-django library which then went and also installed social-auth-core. So please note that both these libraries are installed.
Here is my py -m pip list output proving such:
Package Version
---------------------- ---------
asgiref 3.4.1
certifi 2021.10.8
cffi 1.15.0
charset-normalizer 2.0.7
colorama 0.4.4
cryptography 35.0.0
defusedxml 0.7.1
Django 3.2.9
ecdsa 0.17.0
idna 3.3
oauthlib 3.1.1
pip 21.3.1
pyasn1 0.4.8
pycparser 2.21
PyJWT 2.3.0
python-dotenv 0.19.2
python-jose 3.3.0
python-social-auth 0.3.6
python3-openid 3.2.0
pytz 2021.3
requests 2.26.0
requests-oauthlib 1.3.0
rsa 4.7.2
setuptools 57.4.0
six 1.16.0
social-auth-app-django 5.0.0
social-auth-core 4.1.0
sqlparse 0.4.2
urllib3 1.26.7
As you can see, I'm running Django 3.2.9. I am also using Python 3.10.
After following all of Auth0's steps, I went to run py manage.py migrate and receive the following ending error message:
ModuleNotFoundError: No module named 'social_django'
What I have tried
I have tried uninstalling and reinstalling the social-auth-app-django and social-auth-core libraries multiple times. I have also tried installing the libraries individually instead of just installing social-auth-app-django. I have also tried installing social-auth-app[django] (using brackets). Nothing has worked.
Every post I can find online is telling the OP to install the social-auth-app-django library and that should fix their problem. But as demonstrated, I believe I've already done that. So unless there's a different way I need to install the library, I need a different solution.
Any and all help would be greatly appreciated. Thank you!
Huge credit to #furas in the comments helping point me in the right direction.
The Solution: Reinitialize the virtual environment using python 3.10 instead of python 3.8 and reinstall necessary packages.
Explanation: The problem was that I had inadvertently created my venv using python 3.8. So even though I'd run py -m pip list successfully while inside of the 3.8 venv, all of my packages were still installed using python 3.8. So when I'd try and migrate using python 3.10, the packages weren't viewable.

Pandas will not import because of "dateutil.tz" inside git repo, runs fine outside

I've tried uninstalling and reinstalling Anaconda. and upgrading pandas and most other questions that ask this question. I am working with a brand new installation of Anaconda. with python 3.7, Why is pandas not importing normally?
I have tried manually installing pip install pytz --upgrade and pip install python-datutil --upgrade to no avail. However, After doing these two commands I can now import pandas in the terminal but not in my script where i need it.
The Script where i am trying to import pandas is inside a git repo that perhaps needs to be reconfigured. I suspect that might be the issue. but im not sure how to change how python interacts with pandas from within git.
Here is the stacktrace...
File "C:\Users\jgreaves\Anaconda3\lib\site-packages\pandas\__init__.py", line 37, in <module>
f"C extension: {module} not built. If you want to import "
ImportError: C extension: No module named 'dateutil.tz'; 'dateutil' is not a package not built. If you want to import pandas from the source directory, you may need to run 'python setup.py build_ext --inplace --force' to build the C extensions first.```
Here is the config of my virtual environment
```# Name Version Build Channel
ca-certificates 2020.1.1 0 anaconda
certifi 2020.4.5.2 py38_0 anaconda
numpy 1.18.5 pypi_0 pypi
openssl 1.1.1g he774522_0 anaconda
pandas 1.0.4 pypi_0 pypi
pip 20.0.2 py38_3 anaconda
pyodbc 4.0.30 pypi_0 pypi
python 3.8.3 he1778fa_0 anaconda
python-dateutil 2.8.1 pypi_0 pypi
pytz 2020.1 pypi_0 pypi
regex 2020.6.8 pypi_0 pypi
setuptools 47.1.1 py38_0 anaconda
six 1.15.0 pypi_0 pypi
sqlite 3.31.1 he774522_0 anaconda
vc 14.1 h0510ff6_4 anaconda
vs2015_runtime 14.16.27012 hf0eaf9b_2 anaconda
wheel 0.34.2 py38_0 anaconda
wincertstore 0.2 py38_0 anaconda ```
So after having a friend of mine take a look at my directory. We discovered that I had a file in my working directory called "dateutil.py" which was supposed to be a module for my code that I very uncleverly named. This was what was causing the issue. I have since renamed the file and everything is working fine now.

Can't upgrade python-dateutil in OSX

I am trying to install Sphinx on OSX, with the hopes of eventually making it into a website, following this guide :
I have been macporting, homebrewing, python wheelin', figuring out what a virtualenv is... figuring out if I should use python 2.7 or 3.X (which I couldn't figure out)
I added this to my bash profile :
export PYTHONPATH=$PYTHONPATH:/usr/local/lib/python2.7/site-packages
When I run this :
python -c "import sys; print('\n'.join(sys.path))"
I had expected it to return simply /usr/local/lib/python2.7/site-packages
but it says the following :
/Library/Python/2.7/site-packages/pip-10.0.0b2-py2.7.egg
/Library/Python/2.7/site-packages/virtualenv-15.2.0-py2.7.egg
/Users/nook
/usr/local/lib/python2.7/site-packages
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload
/Users/nook/Library/Python/2.7/lib/python/site-packages
/Library/Python/2.7/site-packages
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python
Anyway, I finally got a virtualenv set-up, and ran the following command:
pip install sphinx
I sorted out a NumPy error, and another error with six. But I am unable to get rid of the following error :
jupyter-client 5.2.3 has requirement python-dateutil>=2.1,
but you'll have python-dateutil 1.5 which is incompatible.
When I run the following command :
pip install python-dateutil --upgrade --ignore-installed
I get
Collecting python-dateutil
Using cached python_dateutil-2.7.2-py2.py3-none-any.whl
Collecting six>=1.5 (from python-dateutil)
Using cached six-1.11.0-py2.py3-none-any.whl
Installing collected packages: six, python-dateutil`
That seems good...
But when I try to install sphinx again I get the same
jupyter-client 5.2.3 has requirement python-dateutil>=2.1, but you'll have
python-dateutil 1.5 which is incompatible.
So I went in and tried the following command :
sudo rm -rf /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/python_dateutil-1.5-py2.7.egg-info/
I want to remove that directory, to NumPy directories, and another dateutil directory...but can't ! I don't have the permissions.
If anyone has a pro-tip on what version of python to use for my sphinx site (the latest version ?), and how set up a virtual environment with **that version of python, figure out Numpty and dateutil... I will be forever in your debt !
EDIT : Just tried the following :
sudo pip install python-dateutil
Password:
The directory '/Users/nick/Library/Caches/pip/http' or its parent directory is
not owned by the current user and the cache has been disabled. Please check
the permissions and owner of that directory. If executing pip with sudo, you
may want sudo's -H flag.
The directory '/Users/nick/Library/Caches/pip' or its parent directory is not
owned by the current user and caching wheels has been disabled. check the
permissions and owner of that directory. If executing pip with sudo, you may
want sudo's -H flag.
Requirement already satisfied: python-dateutil in
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python
(1.5)
pandas 0.22.0 has requirement numpy>=1.9.0, but you'll have numpy 1.8.0rc1
which is incompatible.
matplotlib 1.3.1 has requirement numpy>=1.5, but you'll have numpy 1.8.0rc1
which is incompatible.
jupyter-client 5.2.3 has requirement python-dateutil>=2.1, but you'll have
python-dateutil 1.5 which is incompatible.
You can see my numpy is totally budget too, at 1.8.0rc1. Thanks.

How can I separate out dependencies from requirements.txt?

I am maintaining a requirements.txt file for my Python project, including version numbers and hashes for each package. (This is so I can install with pip install --no-deps --require-hashes.)
Some packages in the list are my actual requirements (for example, Sphinx) while others are just dependencies of those requirements (for example, everything else you get when you pip install Sphinx).
I want to maintain this list of requirements separately from those dependencies. How can I do this?
At the moment I have simply split my requirements into two files (see below, simplified for readability). But I am not sure how maintainable this will be (false retentions, handling dependency updates...).
requirements.txt
# these are my actual requirements
-r dependencies.txt
Sphinx
dependencies.txt
# these are the dependencies of my actual requirements
alabaster
Babel
certifi
chardet
docutils
idna
imagesize
Jinja2
MarkupSafe
Pygments
pytz
requests
six
snowballstemmer
sphinxcontrib-websupport
urllib3

Force virtualenvironment to create an empty environment

I am new to virtualenvironment and an advanced beginner in python.
I am trying to run a jupyter notebook but it seems that when I create a virtualenvironment the jupyter kernel used is the one of my system and not the one of the virtualenvironment I created.
For this reason I am trying to understand how to create a clean virtualenvironment.
What I do is the following:
- Create virtualenvironment named testenv1:
virtualenv -p python3 testenv1
- activate testenv1:
source testenv1/bin/activate
Here it starts something I don't understand. If I list all the packages installed I have a lot of them already. Is there a way to force a completely clean virtualenv?
Thanks.
pip list
Package Version
----------------------------- -------
actionlib 1.11.13
angles 1.9.12
bondpy 1.8.3
camera-calibration 1.12.23
camera-calibration-parsers 1.11.13
catkin 0.7.20
cv-bridge 1.12.8
diagnostic-analysis 1.9.3
diagnostic-common-diagnostics 1.9.3
diagnostic-updater 1.9.3
dynamic-reconfigure 1.5.50
gazebo-plugins 2.5.19
gazebo-ros 2.5.19
gencpp 0.6.0
geneus 2.2.6
genlisp 0.4.16
genmsg 0.5.11
gennodejs 2.0.1
genpy 0.6.7
image-geometry 1.12.8
interactive-markers 1.11.5
joint-state-publisher 1.12.15
laser-geometry 1.6.5
message-filters 1.12.14
pip 20.0.2
pluginlib 1.11.3
python-qt-binding 0.3.7
qt-dotgraph 0.3.17
qt-gui 0.3.17
qt-gui-cpp 0.3.17
qt-gui-py-common 0.3.17
resource-retriever 1.12.6
rosbag 1.12.14
rosboost-cfg 1.14.6
rosclean 1.14.6
roscreate 1.14.6
rosgraph 1.12.14
roslaunch 1.12.14
roslib 1.14.6
roslint 0.11.0
roslz4 1.12.14
rosmake 1.14.6
rosmaster 1.12.14
rosmsg 1.12.14
rosnode 1.12.14
rosparam 1.12.14
rospy 1.12.14
rosservice 1.12.14
rostest 1.12.14
rostopic 1.12.14
rosunit 1.14.6
roswtf 1.12.14
rqt-action 0.4.9
rqt-bag 0.4.12
rqt-bag-plugins 0.4.12
rqt-console 0.4.9
rqt-dep 0.4.9
rqt-graph 0.4.11
rqt-gui 0.5.0
rqt-gui-py 0.5.0
rqt-image-view 0.4.14
rqt-launch 0.4.8
rqt-logger-level 0.4.8
rqt-moveit 0.5.7
rqt-msg 0.4.8
rqt-nav-view 0.5.7
rqt-plot 0.4.8
rqt-pose-view 0.5.8
rqt-publisher 0.4.8
rqt-py-common 0.5.0
rqt-py-console 0.4.8
rqt-reconfigure 0.5.1
rqt-robot-dashboard 0.5.7
rqt-robot-monitor 0.5.8
rqt-robot-steering 0.5.9
rqt-runtime-monitor 0.5.7
rqt-rviz 0.5.10
rqt-service-caller 0.4.8
rqt-shell 0.4.9
rqt-srv 0.4.8
rqt-tf-tree 0.6.0
rqt-top 0.4.8
rqt-topic 0.4.11
rqt-web 0.4.8
rviz 1.12.17
sensor-msgs 1.12.7
setuptools 46.1.3
smach 2.0.1
smach-ros 2.0.1
smclib 1.8.3
tf 1.11.9
tf-conversions 1.11.9
tf2-geometry-msgs 0.5.20
tf2-kdl 0.5.20
tf2-py 0.5.20
tf2-ros 0.5.20
topic-tools 1.12.14
wheel 0.34.2
xacro 1.11.3
WARNING: You are using pip version 20.0.2; however, version 20.1 is available.
You should consider upgrading via the '/home/schiano/virtualenvs/testenv1/bin/python -m pip install --upgrade pip' command.
Main python installed in your system already have the packages in it. and when you try to create a virtual environment in your system, it create a copy of the main python environment.
you can uninstall all the packages from main python environment by running:
pip uninstall <package name>
It will ask you for your permission for removal, press y.
or if you want to do it in one go:
pip freeze > any_path_on_your_system/requirements.txt
pip uninstall -r any_path_on_your_system/requirements.txt
it will ask for your permission for each uninstall. press y
Install package virtualenv
pip install virtualenv
In this way, all the packages from main python will be removed and then, try your method of creating virtual environment.
reference: https://docs.python-guide.org/dev/virtualenvs/

Categories