Can't remove python package - python

I'm trying to remove a package I apparently installed sometime ago (can't remember really) and I'm finding it harder than I thought it would be (the package's name is astropy).
If I do:
import pip
inst_packgs = pip.get_installed_distributions()
inst_packgs_lst = ["%s" % (i.key) for i in inst_packgs]
print inst_packgs_lst
the package is listed as installed.
but if I try:
pip list
the package is not listed as installed.
If I do:
pip search astropy
the package is listed as an available package in PyPi.
If I try:
pip uninstall astropy
I get:
Cannot uninstall requirement astropy, not installed
Storing debug log for failure in /home/gabriel/.pip/pip.log
Why is this not working? How should I remove this package from my system?
UPDATE
pyenv is installed in my system and it was set to a different version locally, which is why the package didn't show. Sorry everybody, this question should be closed/deleted.

https://pip.pypa.io/en/latest/reference/pip_search.html
pip search your_query
"searchs for PyPI packages whose name or summary contains your_query".
astropy exists in PyPI but is not installed in your system
Try :
pip list
instead to get a list of installed packages.

Answering my own question for completeness sake.
pyenv was installed in my system and it was set to a different version locally, which is why the package didn't show.

Related

default python packages after first installation

How can I understand which libraries are installed by default by python after first installation? there is a default list packages of python 3.10?
How can I separate libraries that I have installed after the first default python installation? How can i manage them using pip visualizing also the installation date?
thank you
Here you can find the list of standard library packages installed: Python Libraries.
Furthermore I suggest you to use virtualenv in order to separate the future packages in different projects.
In order to get installation date and hour
import pkg_resources, os, time
for package in pkg_resources.working_set:
print("%s: %s" % (package, time.ctime(os.path.getctime(package.location))))
Source code: See when packages were installed / updated using pip

Can't find Brew installed packages on Mac M1 in Pycharm

I'm having trouble installing packages and using them in Pycharm. I've followed various threads (I'm new to Macs and seem to have tried everything) now I'm stuck.
In this case, I want to use the package xgboost.
I have brew installed, after launching a terminal using Rosetta:
%brew install xgboost
Warning: xgboost 1.3.3 is already installed and up-to-date.
It appears installed OK here:
/opt/homebrew/Cellar/xgboost
I also have Python installed here:
/opt/homebrew/Cellar/python#3.9
But no matter how I configure an Interpreter in Pycharm, I can't seem to get the package recognised.
Where have I gone wrong?
I am very unsure exactly how, but I've got this working.
Following: https://abbasegbeyemi.me/blog/homebrew-python-apple-m1
I changed the order of elements in my path:
export PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/homebrew/bin
then a new interpreter in Pycharm using:
usr/local/Cellar/Python#3.9/3.9.2_2/bin/python3.9
Now I can install packages just using pip in pycharm and it works.
This has been 6 hours of pain - warning to anyone who isn't well versed in macs, setting up an M1 for python dev was a complete nightmare for me.
Docs: https://xgboost.readthedocs.io/en/latest/build.html
Pre-built binary wheel for Python
If you are planning to use Python, consider installing XGBoost from a pre-built binary wheel, available from Python Package Index (PyPI). You may download and install it by running
# Ensure that you are downloading one of the following:
# * xgboost-{version}-py2.py3-none-manylinux1_x86_64.whl
# * xgboost-{version}-py2.py3-none-win_amd64.whl
pip3 install xgboost

How to get rid of non-existing module visible in modules list

I'm working with brew python 3.7 distribution on macOS High Sierra. When installing several modules at once via pip install [modules...] I came across several errors that I dealt with at the time.
However now when accessing to modules list via pip list at the beginning of the list the following information is displayed:
Package Version
--------------------------------- -----------
- r
-BB 0.1
-br 5.4.1
-ock 2.0.0
-ocutils 0.15.1
-r 5.4.1
-stropy 3.2.1
absl-py 0.7.1
... remaining normal modules ...
Those 'modules' seem to be parts of names of actually existing modules. With general uninstall procedure like: pip uninstall -BB or
pip uninstall '-BB' I cannot remove none of those 'modules'. How to get rid of them?
it sounds like those packages are dependency of other packages you have installed
you can check the dependency tree with pipdeptree
lookout for those packages you mentioned see if they're dependency of other packages

Where did my python module install to?

I'm running python 3.6 via anaconda 3, using Visual Studio Code.
I followed instructions like these (Interactive Brokers API install) and downloaded the package to a local directory of mine say: c:\dev\pyib, so now the code is in c:\dev\pyib\IbPy-master
I open that directory in command line and run
python setup.py install
All runs ok.
But then my program, which is in c:\dev\pyib says Module not found. (In my case ibapi). The linter is also showing red.
There is no other python installed on this pc.
Where did the package install to? and how do I check that? What will I find where the package installed itself to that shows me its there?
Or do I have to use a trial-and-error with the linter and sys.path.append()? (I tried that with the directory where the files are downloaded to - to no avail)
I'm trying to set up the PYTHONPATH using the "env" in launch.json from Visual Studio Code, as shown in this unaccepted answer.
Current sys.path:
'c:\\dev\\pyIb',
'C:\\Users\\user\\AppData\\Local\\Continuum\\anaconda3\\python36.zip',
'C:\\Users\\user\\AppData\\Local\\Continuum\\anaconda3\\DLLs',
'C:\\Users\\user\\AppData\\Local\\Continuum\\anaconda3\\lib',
'C:\\Users\\user\\AppData\\Local\\Continuum\\anaconda3',
'C:\\Users\\user\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-
packages',
'C:\\Users\\user\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\Babel-2.5.0-py3.6.egg',
'C:\\Users\\user\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\win32',
'C:\\Users\\user\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\win32\\lib',
'C:\\Users\\user\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\Pythonwin'
I deleted the ib directory and re-ran the install. The last line says: Writing C:\Users\user\AppData\Local\Continuum\anaconda3\Lib\site-pac‌​kages\IbPy2-0.8.0-py‌​3.6.egg-info So is the location of the egg-info the location of my undetected module? The actual folder in the site-packages is called ib.
Or could my problems be because of a difference in Lib vs. lib with the lowercase in the sys.path and the uppercase in the actual directory?
But the real question here is still: HOW DO I KNOW WHERE the package was installed what should I search for?
This answer is specific for anaconda3 Python and packages installed using python setup.py install (which is actually using distutils)
Take a look at anaconda3\Lib\site-packages you should see a directory for the package you installed.
The way to know for sure where your package is, is by doing a pip list then trying to pip uninstall and re-install again using the python setup.py install: Here are the detailed instructions:
When uninstalling, pip will tell you it cannot because it was done via distutils.
You'll get a message like this:
DEPRECATION: Uninstalling a distutils installed project (ibpy2) has been deprecated and will be removed in a future version.
This is due to the fact that uninstalling a distutils project will only partially uninstall the project.
You'll be prompted to continue anyway. If you choose No, then you can find the directory in
C:\Users\<yourusername>\AppData\Local\Continuum\anaconda3\Lib\site-packages
Thanks to Emanuel Mtali for pointing me in the right direction
Some more information:
The problem I had was due to a stupid mistake of mine. I was running setup of a different (but related) package not used anymore. IbPy2 instead of TwsAPI. I was supposed to run the setup.py of the package installed via the latest version of the MSI from IB, and NOT the IbPy2 package. :-(

Enthought Canopy Psycopg2 Install

I'm running into problems installing Psycopg2 using the package manager of Enthought Canopy. I get an error that says the following:
Action: install Psycopg2Database-0.2.0-1.egg
The package manager has encountered error
Loop in dependency graph
[u'DatabasePipe-2.2.1-1.egg', u'PipeStack-0.5.3-1.egg', u'Psycopg2Database-0.2.0-1.egg', u'SQLite3Database-0.2.0-1.egg']
I tried installing the packages listed in the error message, but they also don't install either. Seems like there is something messed up in the dependencies. I have tried installing both under Mac OS and Win 7, same error.
The Psycopg2Database package is not in the Canopy / EPD repository.
Rather, it is in the "Community" (PyPi mirror) repo (marked by the "PyPI" logo in the Package Manager), which contains 11,000 untested ("as is") packages. Most of the packages are current and we are in the process of updating the rest, as well as keeping it updated from now on. Please note that we do not test for nor necessarily provide dependencies.
Meanwhile, this may help:
"Installing external packages into Canopy Python"

Categories