pip not working - python

I am trying to install python-shapely with pip in Ubuntu 10.04. I got "Unknown or unsupported command 'install'" while I tried,
user#desktop:~$ pip install Shapely
I tried installing pip and got the following error:
user#desktop:~$ sudo apt-get install python-pip
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
python-pip
0 upgraded, 1 newly installed, 0 to remove and 396 not upgraded.
Need to get 0B/49.8kB of archives.
After this operation, 270kB of additional disk space will be used.
(Reading database ... 252574 files and directories currently installed.)
Unpacking python-pip (from .../python-pip_0.3.1-1ubuntu2.1_all.deb) ...
dpkg: error processing /var/cache/apt/archives/python-pip_0.3.1-1ubuntu2.1_all.deb (--unpack):
trying to overwrite '/usr/bin/pip', which is also in package pip 0:0.13-1
Errors were encountered while processing:
/var/cache/apt/archives/python-pip_0.3.1-1ubuntu2.1_all.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
I'd appreciate any comment/solution.
Thanks!

Did you install pip first, then get this error, then try to install python-pip?
If so, first remove pip (apt-get remove pip), then install python-pip instead and try again.
(I just had the same problem, not sure if python 2.7 uses pip and 2.6 uses python-pip? That might be the issue.)

Same happen to me, I'm running Ubuntu Lucid Lynx, 10.04 and there's a packaging conflict. Package pip (pearl installation software) has a conflict with the python-pip package. Both of them try to put a pip binary at /usr/bin/pip. You could do several things to solve the problem so choose the one that fits your needs:
1.- Remove "the pearl pip" if you don't use it and install the python pip
2.- Force installation of python pip with some "dpkg -f" or so, but this way your pip binary file will be overwritten
3.- Manually install ether of the packages changing the binary name, i.e. you manually install the python pip and instead of pip you just call the binary "python-pip"

Seems to be broken download. Did you try easy_install?
sudo easy_install pip

The problem raise because pip is in strawberry perl and Python both, if Perl's pip hit this error comes
$ which pip
/cygdrive/c/strawberry/perl/bin/pip
Solution
1. C:\Python27\Scripts\pip install south
or
2. Keep python path before strawberry perl
or
3. remove strawberry perl path from path variable...

Leave everything, Install latest version of python from its https://www.python.org/downloads .It already contain PIP, so open CMD from start and give him path to reach folder where python is installed and open "Script" folder where pip is build-in installed e.g. c:\Python36-32\Script And then write pip install module_name and enjoy,,,
Possibly you will have to open Administrator CMD, SO after typing cmd in start when you see CMD is on list press CTRL+SHIFT+ENTER and press OK in pop-up dialog and you will have administrative CMD.

Related

Error "Invalid version: '0.23ubuntu1' (package: distro-info)"

Originally, my app crashed with error ERROR: Failed building wheel for pycairo (in the picture)
Failed to build pycairo
I tried to fix it by running several commands
sudo apt install libcairo2-dev
sudo apt install cloud-init
Gave the same error. No fix.
then I tried uninstalling the requirements.txt and reinstalled
pip uninstall -r requirements.txt
pip install -r requirements.txt
Did not solve the issue.
then I tried the below command, but I still got the same error "Failed building wheel for pycairo":
pip3 install --upgrade pip (from this thread: ERROR: Could not build wheels for scipy which use PEP 517 and cannot be installed directly
then I tried this command:
pip install --upgrade pip setuptools wheel
and I got this error in the picture: "Invalid version: '0.23ubuntu1'"
Invalid version: '0.23ubuntu1'
I tried to also delete this package but it's showing that package not found:
command I used: sudo apt-get remove distro-info
Error:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package 'distro-info' is not installed, so not removed
0 upgraded, 0 newly installed, 0 to remove and 283 not upgraded.
I searched for solutions but did not find any regarding the error "Invalid version: '0.23ubuntu1'". Now, when I run "flask run", I get error: -bash: /home/ktai/.local/bin/flask: No such file or directory
Would appreciate any help!
I tried several command lines but nothing worked
I learned from this answer that there is a "bug" with versions of setuptools causing this specific Invalid version: '0.23ubuntu1' error.
Despite seeing errors with all sorts of pip commands including pip install, I was surprised to see that this downgrade command (from the answer linked) appears to resolve the issue:
pip install --upgrade --user setuptools==58.3.0
Are you using ubuntu 20.04 by chance?
I had a similar issue but it had to do nothing with pycairo so the situation might be different for you.
The existence of distro-info (with a version not compliant to PEP-440) among my Python packages was leading to the error message from your post's title whenever i tried to install another package.
For me, this one helped: (so you were close with the apt-get remove...)
python3 -m pip uninstall -y distro-info
In my case, it seems like it didnt break anything important so i will keep it like this.
But there is no guarantee the same works for you as well. Also, you might get it back the next time you install packages from your requirements.txt file.
If I understood this thread correctly, there might be updates with a compliant version of this package depending on which Ubuntu version you are using.
This error arises from PEP 440 (Python Enhancement Proposal #440), which enforces conventions for naming of Python packages, and this error seems to really only happen on Debian-based distros like Ubuntu. For example, I have been trying to install a package via pip and get an error:
pkg_resources.extern.packaging.version.InvalidVersion: Invalid version: '1.1build1' (package: distro-info)
So it's telling us that 1.1build1 is an invalid version name per PEP 440, and it's probably getting the distro-info package from, in my case, Ubuntu (came preinstalled).
I can get around this by using a Python virtual environment and not allowing it to use system-site-packages, sometimes called "global packages".
The solution is to remove the offending package and reinstall a version of it that meets PEP 440 requirements (e.g. following the "0.0.0" convention. "1.2.0" for example is fine, "1.2build3" is not).
pip uninstall -y distro-info
pip install distro-info==1.0
Additionally, within PyCharm, I can navigate to the Python Interpreter settings, choose the interpreter I am using from the Python Interpreter dropdown, and confirm that the version of distro-info it's trying to use is 1.1build1. To "upgrade" this to 1.0, I can double-click on the "1.0" under the "Latest Version" column and select "Install Package" from the modal that pops up.
If this or the above command to remove distro-info isn't working, you can use this same window to remove distro-info and then simply run pip install distro-info==1.0.
Thank you for all the answers. To answer my own question, I was finally able to fix the issue by updating all the required packages.
Now there are no updates needed, and the app works again.
0 updates can be applied immediately.
The list of available updates is more than a week old.
To check for new updates run: sudo apt update

Syntax Error from 'pip install' in python + command line

Okay, so, I'm running Python 3.4.3 with pip 9.0.1, with the setuptools and wheel.
I'm running this inside JetBrains PyCharm Professional 2017.2.3.
The issue I'm having is trying to install the twitter api packages from this tutorial (ya I'm a n00b) http://wiki.openhatch.org/Twitter
I'm struggling with installing the 4 dependencies mentioned in the first part of the tutorial (httplib2, simplejson, oauth2 and python-twitter)
Honestly, I'm just getting back into programming and this is a project I'd like to complete.
So, I need help with:
Installing pip, and how to use it, and where (python shell or command line or)
the dev.twitter.com website (and where to find what I need from there)
Any help is massively appreciated and sorry if I sound really n00by, but do correct me where I'm using incorrect terms etc because that's how I learn I guess :)
If you haven't got pip installed, find your python installation file.Execute it and choose 'Change Python Installation'. Now choose 'pip' to install and 'add python.exe to path'. Wait for it to finish. Now run windows command line and type:
pip install package_name
Sometimes you may experience that a package isn't available on pip or doesn't work.There are 2 common (not always working) ways to install a package without making pip download the file:
1) A package may be available as a .whl file for download.Download it.Now find it and copy its name .Open a command line in dictionary where it is located and type
pip install **now paste the filename and add .whl**'
2)A package is available as a zip file.Packages are often packed into a zip file.Download the file and extract it.Open a command line in it's directory.You may see setup.py file.Run
python setup.py install
When finished installing pip and adding python to path,you can run:
pip install httplib2 simplejson oauth2 python-twitter
Done.
Once you have pip installed, open the command prompt and just type pip install name_of_the_extension.
In this case, pip install httplib2 will install this package.
I believe you have pip installed on your computer, so it shouldn't be a problem to install the 4 packages you need.

How to properly install wxPython?

So I was looking around at different things to do on Python, like code for flashing text or a timer, but when I copied them into my window, there were constant syntax errors. Now, maybe you're not meant to copy them straight in, but one error I got was 'no module named wx'. I learned that I could get that module by installing wxPython. Problem is, I've tried all 4 options and none of them have worked for me. Which one do I download and how do I set it up using Windows?
Thanks
It's on PyPI. As of wxPython 4, Python 3 is supported.
Unfortunately, PyPI has a package called wx that is stuck at version 3.0.3; be sure to install the package named wxpython instead.
pip install wxpython
Please note that pip will automatically build wxWidgets for you, but it will not install wxWidgets system dependencies such as GTK and OpenGLu. If the above command exits with an error, look above for a message like this:
checking for <something>... not found
checking for <something>... no
configure: error: <prereq> libraries not available
Error running configure
ERROR: failed building widgets
This should give you information about at least one of the packages your system is missing.
The "official" list of prerequisites from the wxWidgets source is:
dpkg-dev
build-essential
libjpeg-dev
libtiff-dev
libsdl1.2-dev
libgstreamer-plugins-base0.10-dev # or 1.0 if available
libnotify-dev
freeglut3
freeglut3-dev
libsm-dev
libgtk-3-dev
libwebkitgtk-3.0-dev # or libwebkit2gtk-4.0-dev if available
libxtst-dev
The actual package names provided by your package manager may not match these exactly, and to be honest, I don't really know the best way to query a package manager to determine what packages provide the libraries you need.
3 steps to install wx-widgets and pygame in python IDLE
Install python 3xxx in your system opting (Add 3xxx to your path).
open python CLI to see whether python is working or not.
then open command prompt (CMD).
type PIP to see whether pip is installed or not.
enter command : pip install wheel
enter command : pip install pygame
To install wxpython
enter command : pip install -U wxPython
Thats all !!
As per home page instruction:
Make sure you have at least version 6.0.8 of pip and 12.0.5 for setuptools.
Install requirements for Linux as outlined in the readme.rst at:
https://github.com/wxWidgets/Phoenix/blob/master/README.rst
Install wxPython-Phoenix (Linux):
sudo pip install --upgrade --trusted-host wxpython.org --pre -f http://wxpython.org/Phoenix/snapshot-builds/ wxPython_Phoenix
Install wxPython-Phoenix (Windows, use the appropriate script folder):
C:\python27\scripts\pip.exe install --upgrade --trusted-host wxpython.org --pre -f http://wxpython.org/Phoenix/snapshot-builds/ wxPython_Phoenix
I installed wxPython as part of the PsychoPy experiment builder dependencies, and had considerable trouble getting it to install properly as well initially. But this was what worked for me at the end. I use Ubuntu 16.04, python 3.5, pip3 19.0.3
pip3 install -U -f https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-16.04 wxPython --user
If you use Conda then you may easily setup the environment with wx by one line:
$ conda create -n wxenv python=3 wxPython
Solving environment: done
## Package Plan ##
environment location: /home/user/.conda/envs/wxenv
added / updated specs:
- python=3
- wxpython
The following packages will be downloaded:
package | build
---------------------------|-----------------
[...]
Proceed ([y]/n)?
You need to ensure the versions of your wxPython download matches your installed python language library.
The current downloads wxPython downloads doesn't show any libraries built against python 3. I Believe the python 3 porting project is still ongoing.
If you are not sure of what you are doing I would stick with the 32bit version on windows as there are some Python libraries (ie IIRC, MySQLdb) which don't work with 64 bit python.
So you would then need to download python2.7 for windows x86 and "wxPython3.0-win32-py27 32-bit Python 2.7"
To install wxPython GUI library correctly go to the following page (https://wxpython.org/Phoenix/snapshot-builds/), which contains snapshots builds of wxPython library (Phoenix version) depending on your os and version of Python you want to work.
Then when you downloaded the proper package for your system and python version, simply install it by using pip. In my case I've choosen that one (wxPython_Phoenix-3.0.3.dev2811+ecc4797-cp36-cp36m-win_amd64.whl):
pip install wxPython_Phoenix-3.0.3.dev2811+ecc4797-cp36-cp36m-win_amd64.whl
To check that it has been installed sucessfully on the site-packages folder for your current python environment write:
pip freeze
It's all!
Check the version of wxpython and the version of python you have in your machine.
For python 2.7 use wxPython3.0-win32-3.0.2.0-py27 package
The problem was solved in openSuse simply with
zypper in python-wxWidgets-3_0-devel
Trying pip install before, gave me a lot of trouble (missing traits, missing wx/setup.h, https://github.com/wxWidgets/Phoenix/issues/1644, error: aggregate ‘wxGLAttributes _NullGLAttributes’ has incomplete type and cannot be defined, etc.).
wxpython failed to be installed with pipenv. Pipenv is not able to find wxpython binary so it tries to build wxpython but fails.
CXXFLAGS="-I/opt/homebrew/include" pipenv install wxpython
On my macOS M1 pipenv failed to install wxPython. After a lot of searching I found a forum post which really helped me fix the problem.
Source/Credits: https://forums.wxwidgets.org/viewtopic.php?t=47953&p=203709
Install current development version with:
pip install -U https://github.com/robotframework/RIDE/archive/master.zip
(python < 3.9) Install current Beta version (2.0b1) with:
pip install psutil
pip install -U --pre robotframework-ride
Note that I tried to install wxPython with 'pip install -U wxPython' as per instruction
with no avail. Too many errors to list here. 🤨
I found a solution to the problem!!
I'm working on a 64b machine and Windows 11 operating system using VSCode.
Here is the solution using PowerShell:
Version specs:
pip 22.3.1
virtualenv 20.15.1
python 3.10.8
Create a new virtual environment in the directory where the program resides and
activate. There must be no modules installed.
virtualenv venv
venv/scripts/activate.bat
Install the following in sequence:
pip install pygame
(Not sure why pygame must be installed first, but this was
recommended and it works) 😟
pip install -U wxPython
SUCCESS!!! 🤠
These are the modules installed:
numpy 1.24.1
Pillow 9.4.0
pip 22.3.1
pygame 2.1.2
setuptools 65.4.0
six 1.16.0
wheel 0.37.1
wxPython 4.2.0
VSCode still reports wx as a missing module even when you activate the virtual
environment within. Running the code from the PS command prompt within the virtual
environment is the only working solution.
PS. I am sure there are some conflicts when trying to install wxPython within an
environment where all the other modules are installed.

How to install pip in python 3.4 on windows?

I'm really struggling at installing any python modules (e.g six, yahoo_finance) because they require pip to be installed, but I don't know whether I have pip already or how to install it. Once its installed I don't know what command to type in and where to type it in. Can I install these modules any other way without pip?
I am only a beginner, so sorry if this is a bit basic.
Thanks in advance
pip comes already bundled with python 3.4 It will be in your scripts directory C:\Python34\Scripts\
Add it to your Environment variables and you can run it from any directory or else open the directory mentioned above in command prompt and run pip install ... to install whatever you want
First, make sure you have it installed, if not follow the instructions below. Type which pip, and if it doesn't list an URL, it means it's not installed yet.
Go here https://bootstrap.pypa.io/get-pip.py and download the file.
Then open terminal and go to your downloads folder (or wherever you downloaded it to) and type python get-pip.py to execute the script. If you get an error that says OSError: Permission Denied, or something similar, run it with administrator permissions.
If the installation is successful, you should now have pip installed on your computer. Type pip --version to make sure you have it installed.
To install six and yahoo_finance, type:
pip install six
and
pip install yahoo-finance
If something goes wrong update your question.
From Installing Python Modules:
pip is the preferred installer program. Starting with Python 3.4, it is included by default with the Python binary installers.
Emphasis mine
If you already installed it by default you should be able to use it.
Just open the command line and type python -m pip install SomePackage.

Why is pip installing an old version of my package?

I've just uploaded a new version of my package to PyPi (1.2.1.0-r4): I can download the egg file and install it with easy_install, and the version checks out correctly. But when I try to install using pip, it installs version 1.1.0.0 instead. Even if I explicitly specify the version to pip with pip install -Iv tome==1.2.1.0-r4, I get this message: Requested tome==1.2.1.0-r4, but installing version 1.1.0.0, but I don't understand why.
I double checked with parse_version and confirmed that the version string on 1.2.1 is greater than that on 1.1.0 as shown:
>>> from pkg_resources import parse_version as pv
>>> pv('1.1.0.0') < pv('1.2.1.0-r4')
True
>>>
So any idea why it's choosing to install 1.1.0 instead?
This is an excellent question. It took me forever to figure out. This is the solution that works for me:
Apparently, if pip can find a local version of the package, pip will prefer the local versions to remote ones. I even disconnected my computer from the internet and tried it again -- when pip still installed the package successfully, and didn't even complain, the source was obviously local.
The really confusing part, in my case, was that pip found the newer versions on pypi, reported them, and then went ahead and re-installed the older version anyway ... arggh. Also, it didn't tell me what it was doing, and why.
So how did I solve this problem?
You can get pip to give verbose output using the -v flag ... but one isn't enough. I RTFM-ed the help, which said you can do -v multiple times, up to 3x, for more verbose output. So I did:
pip install -vvv <my_package>
Then I looked through the output. One line caught my eye:
Source in /tmp/pip-build-root/ has version 0.0.11, which satisfies requirement <my_package>
I deleted that directory, after which pip installed the newest version from pypi.
Try forcing download the package again with:
pip install --no-cache-dir --upgrade <package>
Thanks to Marcus Smith, who does amazing work as a maintener of pip, this was fixed in version 1.4 of pip which was released on 2013-07-23.
Relevant information from the changelog for this version
Fixed a number of issues (#413, #709, #634, #602, and #939) related to
cleaning up and not reusing build directories. (Pull #865, #948)
I found here that there is a known bug in pip that it won't check the version if there's a build directory with unpacked sources. I have checked this on my troubling package and after deleting its sources from build directory pip installed the required version.
If you are using a pip version that comes with some distribution packages (ex. Ubuntu python-pip), you may need to install a newer pip version:
Update pip to latest version:
sudo pip install -U pip
In case of "virtualenv", skip "sudo":
pip install -U pip
Following command may be required, if your shell report something like -bash: /usr/bin/pip: No such file or directory after pip update:
hash -d pip
Now install your package as usual:
pip install -U foo
or
pip install foo==package.version.here
Got the same issue to update pika 0.9.5 to 0.9.8. The only working way was to install from tarball: pip install https://pypi.python.org/packages/source/p/pika/pika-0.9.8.tar.gz.
In my case the python version used (3.4) didn't satisfy Django 2.1 dependencies requirements (python >= 3.5).
For my case I had to delete the .pip folder in my home directory and then I was able to get later versions of multiple libraries. Note that this was on linux.
pip --version
pip 18.1 from /usr/lib/python2.7/site-packages/pip (python 2.7)
virtualenv --version
15.1.0
Just in case that anyone else hassles with upgrading torchtext (or probably any other torch library):
Although https://pypi.org/project/torchtext/ states that you could run pip install torchtext I had to install it similiar to torch by specifying --find-links aka -f:
pip install torchtext===0.8.1 -f https://download.pytorch.org/whl/torch_stable.html
What irritated me was that PyCharm pointed me to the new version, but couldn't find it when attempting to upgrade to it. I guess that PyCharm uses its own mechanism to spot new versions. Then, when invoking pip under the hood, it didn't find the new version without the --find-links option.
In my case I am pip installing a .tar.gz package from Artifactory that I make a lot of updates to. In order to overwrite my cached Python files and always grab/install the latest I was able to run:
pip install --no-cache-dir --force-reinstall <path/to/tar.gz>
You should see this re-download any necessary files and install those, instead of using your local cache.
10 years on and pip still fails to work as expected 😖.
I wasted a couple of hours now banging my head against the wall trying to find out why pip won't install a development version of my package. In my case, there are versions 0.0.4 and 0.0.5.dev1 in a private gitlab.com package registry (hence the --extra-index-url argument below), but I believe that's not relevant to the problem.
Following a lot of the advice on this page, I create a test venv in a far away folder, clear the pip cache, uninstall the package in question, etc. first to rule out the most common problems:
$ pip cache purge && \
pip uninstall --yes my-package && \
pip install --extra-index-url "https://_:${GITLAB_PASSWORD_TOOLS_VAULTTOOLS}#gitlab.com/api/v4/projects/<project-id>/packages/pypi/simple" \
--no-cache-dir \
--pre \
--upgrade my-package
output (using empty lines to separate output for commands):
WARNING: No matching packages
Files removed: 0
Found existing installation: my-package 0.0.4
Uninstalling my-package-0.0.4:
Successfully uninstalled my-package-0.0.4
Looking in indexes: https://pypi.org/simple, https://_:****#gitlab.com/api/v4/projects/<project-id>/packages/pypi/simple
Collecting my-package
Downloading https://gitlab.com/api/v4/projects/<project-id>/packages/pypi/files/f07 ... 397/my_package-0.0.5.dev1-py3-none-any.whl (16 kB)
Downloading https://gitlab.com/api/v4/projects/<project-id>/packages/pypi/files/775 ... 70e/my_package-0.0.4-py3-none-any.whl (16 kB)
...
Successfully installed my-package-0.0.4
So pip does see the dev package version, but chooses the earlier one nonetheless.
In an attempt to figure out what's going on, I published a 0.0.5 version: Error persists, pip sees all three versions, but still installs 0.0.4.
In a further, increasingly desperate attempt, I removed any versions prior to 0.0.5* from the gitlab.com package registry.
Only now, pip would bother to actually display some useful information:
$ (same command as above)
... (similar output as above) ...
ERROR: Cannot install my-package==0.0.5 and my-package==0.0.5.dev1 because these package versions have conflicting dependencies.
The conflict is caused by:
my-package 0.0.5 depends on my-other-package<0.2.5 and >=0.2.4
my-package 0.0.5.dev1 depends on my-other-package<0.2.5 and >=0.2.4
To fix this you could try to:
1. loosen the range of package versions you've specified
2. remove package versions to allow pip attempt to solve the dependency conflict
ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/topics/dependency-resolution/#dealing-with-dependency-conflicts
OK, so there is something wrong with my package dependencies. Thanks for letting me know.
Seriously - I tried hard for a couple of hours using all kinds of pip ... -vvv and/or fixed versions such as e.g. my-package==0.0.5.dev1 - but I did not manage to get any useful output out of pip - until I wiped the entire history from my package registry 🤬.
Hope this at least helps someone in the same situation.
I found that if you use microversions, pip doesn't seem to recognize them. For example, we couldn't get version 1.9.9.1 to upgrade.
In my case, someone had published the latest version of a package with python2, so attempting to pip3 install it grabbed an older version that had been built with python3.
Handy things to check when debugging this:
If pip install claims to not be able to find the version, see whether pip search can see it.
Take a look at the "Download Files" section on the pypi repo -- the filenames might suggest what's wrong (in my case i saw -py2- there clear as day).
As suggested by others, try running pip install --no-cache-dir in case pip isn't bothering to ask the internet because it already has your answer locally.
I had hidden unversioned files under the Git tab in PyCharm that were being installed with pip install . even though I didn't see the files anywhere else.
Took a long time to find it for me, posting this in hope that it'll help somebody else.
if you need the path for your package do pip -v list. Example see related post when using pip -e Why is an old version of a package of my python library installing by itself with pip -e?

Categories

Resources