reverse pip install "-e" option [duplicate] - python

This question already has answers here:
How to uninstall editable packages with pip (installed with -e)
(7 answers)
Closed 2 years ago.
While developing a package I installed it through pip install -e .
Now when I pip uninstall myPackage I get
Found existing installation: myPackage 0.1.2
Can't uninstall 'myPackage'. No files were found to uninstall.
with pip show myPackage I get:
Location: /mnt/home/aerijman/scripts/myPackage
I don't want to delete the path. How do I uninstall it?
Thank you

Assuming the project's name is MyProject, there should be a MyProject.egg-link file in the site-packages directory for this Python interpreter. Running the command /path/to/pythonX.Y -m site should help you figure out the possible location of this directory. Find the directory, find the MyProject.egg-link file, delete the file. Then you might also need to find a easy-install.pth in a similar site-packages directory (most likely the same), and in this file delete the line mentioning MyProject.

Related

Local repository for *.whl files python [duplicate]

This question already has answers here:
How to setup pip to download from mirror repository by default?
(2 answers)
Closed 5 months ago.
I'm new to python and I need to install *.whl files locally from some folder (repository). I can install *whl like by using the command pip install path_to_file/*.whl, but this is not I want, what I do want is to write pip install some_whl_package and install the package specified from LOCAL directory. How can I do it? I use python 3.8.
Note that the dist folder must contain the whl file.you can also install .tar.gz packages like this
pip install --no-index -f ./dist my_package.whl

How to install a Python package that does not exist in Anaconda Cloud [duplicate]

This question already has answers here:
How to install PyPi packages using anaconda conda command
(3 answers)
Closed 4 years ago.
I use Anaconda as the main source of python packages and also my main interpreter in PyCharm. If I want to install any package, I go to Anaconda Cloud and find it immediately something like this. Now, I want to install a package that only exists in Python Package Index here. I cannot find it in Anaconda Cloud so I don't know how to install it. Do I just need to include the package folder in the project directory in this case?
Thank you
You can install non-conda packages using pip:
pip install python-nonblock

Can't uninstall project with no packages

While trying to build an MCVE for another question, I created an example directory with one file in it, a setup.py with the following contents:
from setuptools import setup
setup(
name='example',
)
and installed it with
python3.6 setup.py sdist
python3.6 -m pip install --user dist/example-0.0.0.tar.gz
No actual packages or modules, but something got installed:
redacted:~/example> python3.6 -m pip list | grep example
DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.
example (0.0.0)
Now I can't uninstall it:
redacted:~/example> python3.6 -m pip uninstall example
Can't uninstall 'example'. No files were found to uninstall.
Other posts suggest there might be a .pth file I have to remove from my site-packages directory, but I don't see any:
redacted:~/example> find ~/.local/lib/python3.6/site-packages/ -name '*.pth'
redacted:~/example>
What did I just do to my system, and how can I undo it?
The steps shown in the question will actually create and install a real package. It won't create any importable files, but it will create metadata in a site-packages directory. Exactly where it has installed depends on your USER_SITE configuration, which you can check with python3.6 -m site, but it's probably going to be at ~/.local/lib/python3.6/site-packages/example-0.0.0-py3.6.egg-info.
Path files (.pth) are unrelated.
The reason it can't uninstall, saying:
Can't uninstall 'example'. No files were found to uninstall.
is because the build command executed earlier will have created an example.egg-info in the current directory, and using python3.6 -m pip means the empty-string is in sys.path. So, the current directory is also considered a package location. Since the current working directory, at sys.path[0], is before the user site the example.egg-info metadata will be found here instead of in site-packages.
The command python3.6 -m pip uninstall also finds this build artifact first, for the same reasons, and does not find the metadata from site-packages which has a record of the files that should be removed during an uninstall. To correctly uninstall this package you could:
rm -rf example.egg-info # first prevent pip from getting confused by the temporary build artifact in cwd
python3.6 -m pip uninstall example # uninstall it from the user site
Or, you could change directory before uninstalling, so that pip finds the package metadata for example in the user site instead of in the working directory.
Note 1: These workarounds are not required for pip >= 20.1. Since April 2020, using python -m pip now ejects the cwd from sys.path and it will uninstall successfully from the user site in the first place without getting confused (#7731)
Note 2: some details are slightly different if this python3.6 environment has a wheel installation in it - in this case the install command will first create a wheel file from the sdist, and then install the wheel, which will result in an example-0.0.0.dist-info subdirectory for the metadata instead of an egg-info subdirectory, but the important details are the same whether you have an .egg-info or .dist-info style install in the user site. It is not possible to determine from the details in the question whether the python3.6 environment had a wheel installation available.
Since you didn't specify any files, there was nothing to be installed. So you can't uninstall anything either.

Installing downloaded tar.gz files with pip [duplicate]

This question already has answers here:
How to install Python packages from the tar.gz file without using pip install
(7 answers)
Closed 4 years ago.
When I download PyGUI-2.5.4.tar.gz from http://www.cosc.canterbury.ac.nz/greg.ewing/python_gui/ and then run
pip install downloads/PyGUI-2.5.4.tar.gz
I get a long error, the root of which appears to be the following:
tarfile.ReadError: not a gzip file
Any ideas what I'm doing wrong?
The correct syntax for the installation is:
pip install --user ./Downloads/PyGUI-2.5.4.tar.gz
The --user is used to give the necessary permissions to install the package. Always check for the correct path and Upper and Lower case in your path(Your path was to 'downloads' with small 'd' ).
You can install tar.gz with pip Install a particular source archive file.
pip install ./Package-1.0.4.tar.gz
You can also install it with extracting tar.gz file. First you should extract it using using tar command.
tar -xzvf PyGUI-2.5.4.tar.gz
cd PyGUI-2.5.4.tar.gz
And then use the setup.py file to install the package .
python setup.py install
or
sudo python setup.py install
( use sudo only in linux )
Source: https://pip.readthedocs.io/en/stable/reference/pip_install/#git

How to install Python package from GitHub? [duplicate]

This question already has answers here:
Configuring so that pip install can work from github
(8 answers)
Closed 6 years ago.
I want to use a new feature of httpie. This feature is in the github repo https://github.com/jkbr/httpie but not in the release on the python package index https://pypi.python.org/pypi/httpie
How can I install the httpie package from the github repo? I tried
pip install https://github.com/jkbr/httpie
But I got an error 'could not unpack'
In Nodejs, I can install packages from github like this
npm install git+https://github.com/substack/node-optimist.git
You need to use the proper git URL:
pip install git+https://github.com/jkbr/httpie.git#egg=httpie
Also see the VCS Support section of the pip documentation.
Don’t forget to include the egg=<projectname> part to explicitly name the project; this way pip can track metadata for it without having to have run the setup.py script.
To install Python package from github, you need to clone that repository.
git clone https://github.com/jkbr/httpie.git
Then just run the setup.py file from that directory,
sudo python setup.py install

Categories