pip freeze doesn't show anything in Windows installation? - python

I have Python27 installed in Windows 7
I am trying to build a reddit bot using this tutorial
I found instructions on how to install pip for windows from here
The page says that after installing pip, I can use pip freeze to check if the installation went correctly
It says pip freeze should display some information as shown below
Microsoft Windows [Version 6.2.9200] (c) 2012 Microsoft Corporation.
All rights reserved.
C:\Users\Username>cd c:\Python27\Scripts
c:\Python27\Scripts>pip freeze
antiorm==1.1.1
enum34==1.0
requests==2.3.0 virtualenv==1.11.6
However pip freeze doesn't show me anything at all
Did pip install correctly, or is there any problem? Is there any other way i can test proper installation?

If you want to test it thoroughly, you can use your actual pip installation to install something. For example, numpy would be a good sized example that can rule many problems out.
> pip install numpy
Now, run pip freeze again to check if pip is working as expected. It should then have something to show.
If you want to test it even further, you can open a terminal and
> python
> import numpy
That should be the complete test of your pip installation.
Additionally, whenever I install a new tool in my stack, I like to validate its path with where <executable name> (on Windows) and which <executable name> (on Linux). There are some compilers like Java that are always conflicting with other installations (like crazy, to the point that a complex setup may sometimes have to inject an absolute path to enforce the use of the correct version).
Also, asking the executable for its version can rule many other problems out. In your case, you can use pip --version to check which version you got and compare it to the stable or latest, according to what you want to use.

windows is a confusing piece of software if your coming from a Linux background... the solution that worked for me is the following
pip list

The problem you are facing is that if you only have de default packages in your installation lets say pip, wheel, pip freeze does not have anything to freeze at the moment so that's why dont show anything. try to install a new package then run the command again.

Related

Pip Install Troubles

Currently trying to get python up and working on my work laptop which has proven to be a huge pain in the you know what.
It seems like the PATHing is all screwed up even with pip installing packages. For example, I tried to install seaborn today via pip install seaborn which ran successfully but when I try to import it on Visual Studio it has the yellow squiggly underneath it. I try to reinstall it but it says it has already been satisfied.
Is there anyway to manually re-route all of my python libraries to where I actually know whats going on? I have the PATH set to the correct library in environment variables but it still does not read that I have seaborn installed.
Any help is greatly appreciated.
You can create python virtual environment and install your libraries on it.
https://linuxize.com/post/how-to-create-python-virtual-environments-on-ubuntu-18-04/
It creates a isolated area for your specific project.
It sounds like you might have different python installations on your system.
If that's the case it might also be the case that the python you are using in visual studio isn't the python that is packages are being installed for via a straight forward pip command.
You could try to instead of pip install ... call python -m pip install .... That ensures that you are using the pip of the python installation
I recommend you to install all dependencies (seaborn, pandas, numpy, matplotlib, etc) in a virtual environment, that means that you can have its own independent set of installed Python packages in its environment.
See here the python documentation on how to work with virtual environments on different OS.
Also, check which python versions you have installed on your machine. If you have both python2 and python3, use pip3 and python3 on terminal whenever you want to install or run something.

What is the difference between installing a package in my Windows CMD and in VS Code terminal?

I am doing this project where i need to install a package called Twint.
I want to install this package and use it's commands in my VS Code.
What happends when i for example type this in my Windows CMD?
pip3 install --user --upgrade git+https://github.com/twintproject/twint.git#origin/master#egg=twint
Because i can't type this in my VS code terminal, where i usually install packages with pip.
It will return an error that says ERROR: Cannot find command 'git' - do you have 'git' installed and in your PATH?''
Now if i run this in my Windows Command it seems that i can't directly import the package in VS code?
Can anyone help me out with this confusion, where does the files get stored and how do i create good habbits around installing packages?
Hope someone understands what im struggeling with here.
Best
It is often the case that computers have more than one version of python installed and that editors like VS code use a different version than pip uses on the command line. pip installs packages where the version of python it is linked to expects them to be, but VScode doesn't know to look there.
It sounds like you have git installed where pip installs things, so you can upgrade from the command line without issue, but there's no installation of git where VScode is looking, so there's nothing to upgrade.
You either need to find where pip installs things and add it to the $PATH VScode uses, or try running a variation of python -m pip install --user git (specifying a specific url, or other things, as needed) from within VScode, which will ensure the package gets installed in a place that VScode looks for packages.
Download and Install git in your windows from here:
https://git-scm.com/download/win
Then add its installation bin path to your windows's environment path. Then you will find the git command at the command prompt globally.
This may solve you problem.

How can I uninstall a corrupted PIP instance on Windows?

Today, I was trying to install Python 3.10.1.
I was successful in this, but, then, as I was installing Flask, pip will tell me that it installed, then, when I run the script, it says nothing is installed.
After a while, I realized I was running my Python scripts in Python 3.10.1, but I was running pip in Python 3.7. I did as this post said and ran pip --version to discover this.
I ran pip show flask to see where the module is, and it's in the Python 3.7 folder.
However, when I tried to uninstall Python 3.7, I can't find it in my start menu or in Control Panel > Programs > Programs & Features. I believe I had uninstalled it a long time ago.
To counteract this, I did as some YouTube video said (I lost the link to it) and re-installed Python 3.10.1, checked the "Add to PATH" option, checked to install for all users, and checked on the pip install.
After doing this, I upgraded my pip version to the latest version, uninstalled Flask, and re-installed it.
It was still installed in the Python 3.7 folder.
Next, I decided I will just uninstall PIP.
I ran CMD as an Administrator and typed pip uninstall pip as instructed here.
However, when I did this, it says I'm missing access to the places it wants to modify.
I found that strange, so I checked if I'm actually running it Administrator, and, yes, I am.
I looked at the directories that it wants to modify and gave ADMINISTRATORS ownership of all of them.
Absolutely nothing changed and did it again.
I gave myself ownership of it and did it again.
Absolutely nothing changed.
Then, I decided to run pip uninstall pip again. It says pip is not installed. That's strange.
I typed pip, and the help command for pip shows up.
Then, I (probably stupidly) went to all the directories and files PIP listed that it wants to uninstall, and manually deleted them, then uninstalled Python 3.10.1, and made sure to install PIP from there.
And now we're back at Python 3.7, and pip still isn't installed somehow.
I don't know what's happening. I haven't coded anything in Python for 2 or 3 years, and I want to try again, but this is starting to confuse me. Could anyone help?
Edit: Based on the suggestion of one of the answerers, I tried to manually delete pip. I couldn't find it in %APPDATA%, but pip --version shows me the path.
I tried deleting pip from there, but it says I need permission from ADMINISTRATORS. I am an administrator on my computer -.-
Anyways, I tried to take ownership of the folder, but nothing ever came of that.
Try to locate %APPDATA%\pip\pip by typing it into the file explorer. Pip will be located there, and you should be able to delete it.
I've managed to fix the issue.
I found that if I press this button in the start menu search for Python 3.7, it's possible to uninstall it from there (Control Panel said it uninstalled it when I used that, but it didn't).
I think I had installed Python from the Microsoft Store, which is why I couldn't find it in %APPDATA%.
Once I did that, I tried to uninstall Python 3.10 then re-install it. It kept saying it's installed, but it wouldn't show up in Command Prompt.
I fixed this by installing Python 3.10 from the Microsoft Store instead.
This fixed the problem.

Ubuntu Python, install packages with user or sudo

I am new at Python and Ubuntu. I really struggle to decide the best way of installing Python packages on Ubuntu. I am using VIM so I cannot use Anaconda since they do no "talk".
I have two options:
Install with: pip3 install --user foo. This works find but according to python4astronomers you should never use --user. It will work very bad.
Use apt-get but then I got old packages
Use sudo pip, but that can get bad code into my system.
I do not want to use virtual environments. I want to be able to use all packages I have installed when I use Python. I normally use Jupyter.
I find it strange that Python installation is so difficult on Linux compared with Windows.
Which of these is the correct way?

How to install pip in a new python installation

I recently installed python 2.7.2 on my Mac running OSX 10.6.8. Previously, I had version 2.6. I set my path in .bash_profile as follows:
export PATH=/usr/local/bin:$PATH
export PATH=/usr/local/share/python:$PATH
so that when I run python it will refer to my new installation. It does.
I would also like to use pip with my new installation, but the problem is that I already have the current version of pip installed at
/usr/local/bin/pip.
I tried to re-install pip with:
easy_install pip
But, of course this does not put pip in the desired new directory
/usr/local/share/python/pip
but simply refers to the existing version in /usr/local/bin/pip.
Can someone tell me how to fix this?
I would like to then use pip to install NumPy and SciPy in the correct directory (I was having trouble getting the SciPy installation to work with my old version of python, hence the new install).
If you'd like, you can visit the website where I found instructions for installing python 2.7, creating/updating my .bash_profile, installing pip, and NumPy and SciPy. Might provide some insight, or I'm happy to give more details if needed. Thanks!
http://www.thisisthegreenroom.com/2011/installing-python-numpy-scipy-matplotlib-and-ipython-on-lion/#python
Install distribute as per the instructions at http://pypi.python.org/pypi/distribute .
Make sure you specify the full path to the python executable (/usr/local/share/python/python or smth in your case).
$ curl -O https://svn.apache.org/repos/asf/oodt/tools/oodtsite.publisher/trunk/distribute_setup.py
$ /usr/local/share/python/python distribute_setup.py
Then you should have /usr/local/share/python/easy_install.
After that, run:
$ /usr/local/share/python/easy_install pip
Then you should have /usr/local/share/python/pip.
Depending on the ordering of things in your PATH, either your old, or the newly installed pip is executed when you execute the pip command, so you either might have to adapt your PATH, or specify the full path to /usr/local/share/python/pip when installing eggs.
(shameless plug:
In any case, you might consider using virtualenv for installing packages into a "project" specific isolated environment, as opposed to installing them globally.)
I needed to uninstall brew's python.
Then, I was left with python v2.7.6
Next to install, pip I ran
sudo easy_install pip
installed fine and working
I had a similar issue, try this:
$ python -m pip install --upgrade --force-reinstall pip
This will force reinstall pip with whatever version of python you use including installing the binary.
A few days ago I had a friend who was starting Python Programming and needed help with the same issue: installing pip. There are debates over which one to choose between easy_install and pip and it seems everybody is heading the pip direction. Either way, installing either of them can be frustrating.
You can use this simple tutorial : installing pip package manager the easy way
Here are what you should keep in mind as you follow the above guide:
If you already have an older version installed, uninstall it or totally remove the python installation
Once that is cleared, download an install Python.
After that, download ez_setup.py file and save it to your desktop - easily accessible from the command line
Now run it from the command line and it will install easy_install for you after which,
You can use it to install pip.
Once again, you can do this or use the above link to find a simple step-by-step guide on how to get it installed on your computer.
Good luck.
Just so that people knew, ATM we can install PIP by downloading get-pip.py from the page with docs and run it like this:
c:\python27\python.exe get-pip.py
BTW, Python 3.4 comes with PIP pre-installed.
One of the command line options lets you choose where to install to.
--install-dir (-d) install package to DIR
So something like - # easy_install pip -d /usr/local/share/python
(Please correct me if I'm wrong.)
Just wanted to say that I found a way to get around my problem. I don't know that I can explain it perfectly, since I am not very good at understanding what I am doing with this stuff just yet! But, the problem seems to have been with my PATH. I removed the PATH that I posted in my original question, and then used easy_install pip. It went straight to python 2.7.2 (my new version) with no problem. I then successfully used pip to install NumPy and SciPy in the correct location, and they both work. Thanks to ErikAllik and FakeRainBrigand for taking the time to look into it!

Categories