How to uninstall scons? - python

I'm downloaded scons 2.3.0 with official site and install it command:
python setup.py install --standard-lib
And i have question how to uninstall scons?
MacOS X 10.8.4

The library itself should be in /usr/local/lib/scons. Executables (scripts) in /usr/local/bin/{scons,sconsign,scons-time,scons.bat}. Scripts may be with version number, e.g. scons-2.3.0. Finaly docs in /usr/local/man/man1.
Also look for the egg file with:
$ find / -name "scons*.egg-info"
Hope that helps.

I realize my answer is similar and could not be possible without the one from #twil but I found more locations to potentially clear up for.
So delete all files which are related to the python version your want to clean up.
On MacOS we have locate so let's use that.
Running locate "egg-info/PKG-INFO" | grep -i scons gives me 2 miniconda locations refering to Python 3. We do not have to clean those up by manually delete those. That is done by the conda way.
Running locate "scons-" | grep -v miniconda give me files in /usr/local/bin/scons and /usr/local/lib/python2.7/site-packages/scons-. You can uninstall using pip depending on your installation location.
To find more 'scons' I had to skip
locate "scons" \
| grep -v miniconda \
| grep -v "python2.7/site-packages" \
| grep -v "/usr/local/bin/scons" \
| grep -v "/Applications" \
| grep -v "/Library" \
| grep -v "/Users"
finds
/opt/X11/include/X11/extensions/dpmsconst.h
/usr/local/Cellar/zsh/5.7.1/share/zsh/functions/_scons
/usr/local/share/mime/text/x-scons.xml
/usr/local/share/zsh/functions/_scons
which you have to handpick yourself for deletion. Ie the zsh file I found was not a target.
Man pages
Man pages are located in /usr/local/share/man.
I cannot find man pages:
man scons
No manual entry for scons
My lesson is always installing scons using Conda (or pip --user) not to corrupt the default MacOS python version.

Related

Transaction check error due to conflicting python versions during packstack install of OpenStack-Train

The packstack installation of openstack is failing with the following error -
/Stage[main]/Nova::Vncproxy/Nova::Generic_service[vncproxy]/Package[nova-vncproxy]/ensure: change from 'purged' to 'present' failed: Execution of '/usr/bin/yum -d 0 -e 0 -y install openstack-nova-novncproxy' returned 1: Transaction check error:
file /usr/bin/websockify from install of python2-websockify-0.8.0-13.el7.noarch conflicts with file from package python3-websockify-0.10.0-3.el8.noarch
file /usr/share/man/man1/websockify.1.gz from install of python2-websockify-0.8.0-13.el7.noarch conflicts with file from package python3-websockify-0.10.0-3.el8.noarch
Above you can see that two files (/usr/bin/websockify & /usr/share/man/man1/websockify.1.gz) are conflicting between python2-websockify & python3-websockify & so any one of them has to be removed but,
while checking the installed packages of the system I can see that python2-websockify is only available in the system but not installed in the system.
[root#controller ~]# yum list | grep -i python2-web
python2-webob.noarch 1.8.5-1.el7 #centos-ceph-nautilus
python2-websocket-client.noarch 0.54.0-1.el7 centos-ceph-nautilus
python2-websockify.noarch 0.8.0-13.el7 centos-openstack-train
[root#controller ~]# yum list installed | grep -i python2-web
python2-webob.noarch 1.8.5-1.el7 #centos-ceph-nautilus
However python3-websockify is installed in the system & I cannot remove it because the nova-novnc package has a dependency on that one.
[root#controller ~]# yum list installed | grep -i python3-web
python3-websockify.noarch 0.10.0-3.el8 #/python3-websockify-0.10.0-3.el8.noarch
Now, how can I remove the python2-websockify.noarch which is not even installed on the system?
& when it is not installed then why the error is mentioning
from install of python2-websockify-0.8.0-13.el7.noarch conflicts with file from package python3-websockify-0.10.0-3.el8.noarch
I tried to delete the python2-websockify but as it is not installed so giving following messages -
[root#controller ~]# yum remove python2-websockify-0.8.0-13.el7.noarch
Loaded plugins: fastestmirror
No Match for argument: python2-websockify-0.8.0-13.el7.noarch
No Packages marked for removal
Problem solved after removing the epel-release because the puppet was coming updated from Epel instead of packstack
#yum autoremove epel-release

How to know what to import into the Python Interpreter in order to use installed python library [duplicate]

This question already has answers here:
How to find "import name" of any package in Python?
(5 answers)
Closed 4 years ago.
I have installed a python library called PyRadiomics by doing:
pip install pyradiomics
When I do pip freeze | grep pyra in the command prompt, I see pyradiomics==2.0.0 clearly showing that the library was installed.
When I start a python interpreter and do import pyradiomics, it does not work. I realized that I need to do import radiomics.
I just happened to figure this out by luck.
How is someone supposed to know how to import a library into their python script after installing it using pip. It seems that currently, you could install a library with pip install some_name and have to do import some_other_name in your Python code. I have been using Python for a while but never came across this before which lead me to assume that some_name is always the same as some_other_name but I found out that this is not the case.
How is someone supposed to know what that other name is after installing a library called some_name
pip can list installed files for any package installed by it:
$ pip show -f packagename
Doing some simple output filtering/transforming with bash, you can easily come up with a custom command that will list all Python packages/modules in a package, for example:
$ pip show -f packagename | grep "\.py$" | sed 's/\.py//g; s,/__init__,,g; s,/,.,g'
Example output with the wheel package:
$ pip install wheel
...
$ pip show -f wheel | grep "\.py$" | sed 's/\.py//g; s,/__init__,,g; s,/,.,g'
wheel
wheel.__main__
wheel.archive
wheel.bdist_wheel
wheel.egg2wheel
wheel.install
wheel.metadata
wheel.paths
wheel.pep425tags
wheel.pkginfo
wheel.signatures
wheel.signatures.djbec
wheel.signatures.ed2551
wheel.signatures.keys
wheel.tool
wheel.util
wheel.wininst2wheel
You can even alias it to a custom shell command, for example pip-list-modules. In your ~/.bashrc (Linux) / ~/.bash_profile (MacOS):
function pip-list-modules() {
pip show -f "$#" | grep "\.py$" | sed 's/\.py//g; s,/__init__,,g; s,/,.,g'
}
Test it:
$ pip-list-modules setuptools wheel pip # multiple packages can passed at once

How to install a binstar package in Anaconda?

I was unable to install -pdfminer- using the source distribution so I was trying to use binstar to do so. Since I am using the Ananconda distribution of Python, I type:
conda install -c https://conda.binstar.org/jacksongs pdfminer
but, get the following error:
Fetching package metadata: ...
Error: No packages found in current win-32 channels matching: pdfminer
You can search for this package on Binstar with
binstar search -t conda pdfminer
Could you please suggest a solution?
Thank you.
PS: binstar search -t conda pdfminer returns the following:
Run 'binstar show <USER/PACKAGE>' to get more details:
Packages:
Name | Access | Package Types | Summary
------------------------- | ------------ | --------------- | --------------------
auto/pdfminer3k | published | conda |
http://bitbucket.org/hsoft/pdfminer3k
jacksongs/pdfminer | public | conda | PDF parser and analyzer
Found 2 packages
This has probably got to do with the choice of platform. Binstar only has a package for OS X 64 whereas I am using windows.
I myself have never used the anaconda distribution of python but judging by the information you have given, have you tried
conda install -c http://bitbucket.org/hsoft/pdfminer3k
Like I said before, I've never used this distribution and I have near to no idea of the solutions you have tried.
I hope I helped,
~Bobbeh
I tried the following: (Anaconda Python 2.7 on Windows 10 64-bit)
This adds the conda-forge channel to your list of channels
conda config --add channels conda-forge
Installs pdfminer
conda install pdfminer
This was my source: conda-forge:pdfminer on github

How can I see all packages that depend on a certain package with PIP?

I would like to see a list of packages that depend on a certain package with PIP. That is, given django, I would like to see django-cms, django-filer, because I have these packages installed and they all have django as dependency.
Update (2021):
Since pip version 10 you can do:
pkg=httplib2
pip show $pkg | grep ^Required-by
or for bash
pkg=httplib2
grep ^Required-by <(pip show $pkg)
so you could create an alias like:
alias pyreq='pip show $pkg | grep ^Required-by'
and querying by:
pkg=httplib2 pyreq
which should give (for ubuntu):
Required-by: lazr.restfulclient, launchpadlib
Original:
Quite straightforward:
pip show <insert_package_name_here>| grep ^Requires
Or the other way around: (sorry i got it wrong!)
for NAME in $(pip freeze | cut -d= -f1); do REQ=$(pip show $NAME| grep Requires); if [[ "$REQ" =~ "$REQUIRES" ]]; then echo $REQ;echo "Package: $NAME"; echo "---" ; fi; done
before that set your search-string with:
REQUIRES=django
essentially you have to go through the whole list and query for every single one. That may take some time.
Edit:
Also it does only work on installed packages, I don't see pip providing dependencies on not installed packages.
I know there's already an accepted answer here, but really, it seems to me that what you want is to use pipdeptree:
pip install pipdeptree
pipdeptree --help
pipdeptree -r -p django
Since version 10, pip show also includes a "Required-by" entry. So just
pip show <package_name>
is enough nowadays. Or possibly
pip show <package_name> | grep ^Required-by
if you want to get just that single line for a script or whatever.
This one, for pip older than 1.3.1 will list all packages and it's dependencies, you can parse its output with any scripting language, for Requires ... django inclusions:
pip freeze | cut -f 1 -d'=' | xargs -L1 pip show
For example, following snippet:
import os
import re
package = 'numpy'
regex = re.compile('.*{}($|,).*'.format(package))
def chunks(l, n): return [l[i:i+n] for i in range(0, len(l), n)]
cmd = "pip freeze | cut -f 1 -d'=' | xargs -L1 pip show"
packages = os.popen(cmd).read()
pkg_infos = chunks(packages.splitlines(), 5)
print '\n'.join(x[1][6:] for x in filter(lambda x: regex.match(x[-1]), pkg_infos))
outputs pandas on my system.
One liner based on requirements.txt. In this example I'm looking for funcsigs reverse dependency, and found mock. Just change funcsigs by something else.
cat requirements.txt | grep -v git | sed 's/==.*//' | xargs -I % echo 'pip show % 2>/dev/null | grep Requires | grep -q funcsigs && echo %' | sh

How to build pgmagick under pythonbrew on OS X?

I'm not having much success when attempting building pgmagick on OS X Lion with XCode 4.3.1.
I've installed both ImageMagick and GraphicsMagick, along side boost, using the following commands (via homebrew):
$ brew install graphicsmagick --with-magick-plus-plus
$ brew install imagemagick --with-magick-plus-plus
$ brew install boost --with-thread-unsafe
then I'm cloning the repo at https://bitbucket.org/hhatto/pgmagick:
$ hg clone https://bitbucket.org/hhatto/pgmagick/src
$ cd pgmagick
$ python setup.py build
However I always receive the following error:
ld: library not found for -lboost_python
collect2: ld returned 1 exit status
Based on the output on stdout, setup is looking in the right place for the boost (/usr/local/lib).
I've also tried easy_install and pip but with no luck. I'm using Pythonbrew but have also disabled this and tried using the stock python install -- still no success.
Any suggestions on how I can fix the problem, or further diagnose the issue?
According to my own reproduction of this issue in brew 0.9 and OSX 10.6.8, the problem is --with-thread-unsafe isn't being honored by the current brew formula file. You can verify this by checking the formula with brew edit boost and seeing if the option appears within the contents of the formula.
Because of this, libboost_python-mt.a and libboost_python-mt.dylib are being built instead of libboost_python.a and libboost_python.dylib.
The easiest ways to fix this are to edit your pgmagick setup.py to replace boost_lib="boost_python" with boost_lib="boost_python-mt" (as pointed out here) or to follow the instructions and patch here. It's otherwise a known issue.
The boost_python lib inside /usr/local/lib/ is named after libboost_python-mt.a and libboost_python-mt.dylib, since the default compiling is w/ multi-threads supporting enabled.
Grep boost_lib="boost_python" under ELSE condition in setup.py and replace it w/ boost_lib="boost_python-mt", will fix the "not found" issue.
Also it's OK to ln "-mt" version to libboost_python.a: as described here for linux boost which no longer appends '-mt' suffix since 1.42.
Ignore this line or you could "with-boost-python=boost_python-mt python setup.py install".
You could probably append '--with-boost-python=boost_python-mt' to extra_compile_args inside setup.py, to achieve the same goal.
Furthermore, you could install pgmagick through pip in managed envs. Refs http://rohanradio.com/blog/2011/12/02/installing-pgmagick-on-os-x/
Note that as of July 2014 the boost Python library is a separate homebrew package called boost-python.
5254f8f510fb30484f8fac8be3d38e388a4392e2
Author: Tim D. Smith <git#tim-smith.us>
Date: Sat Jul 19 15:37:25 2014 -0700
Split out Boost.Python
You need to install it separately to get the libboost_python shared library.
Does setting DYLD_FALLBACK_LIBRARY_PATH=/usr/local/lib in the environment help before the build
e.g
$ export DYLD_FALLBACK_LIBRARY_PATH=/usr/local/lib
$ hg clone https://bitbucket.org/hhatto/pgmagick/src
$ cd pgmagick
$ python setup.py build
I've submitted a pull request to homebrew to build Boost with both mt and non mt (threaded and thread unsafe) binaries which are required to build pgmagick.
Turns out this is a rather common problem, until the patch is accepted, you can check out or use my formula for Boost to build pgmagick.

Categories