I am new to Python (2.7) but I am trying to run a program that requires the "requests" module. I have installed pip using the get-pip.py script and registered the Python27 and Python27/Scripts paths as environment variables.
When I run "python -m pip install -U pip" it says the package is already up-to-date.
Following installation guides, when I run "pip install requests" I get a new command prompt line. I tried "easy_install requests" and get the same thing. I tried "pip install --verbose requests" and have the same behavior (so much for being verbose!).
I am running on Windows Vista Ultimate, using the command prompt as administrator.
Since the "python -m pip install -U pip" actually displayed something, on a hunch I tried:
"python -m pip install requests"
This worked! I don't know why any of the installation guides do not say to do this.
Related
I posted the question below, but none of the answers I was pointed to worked, though they look like they should.
I activated (again) the virtualenv. It still tells me that pip can't be found by apt when doing an 'apt install' command. But here is where I am now, and very confused.
I pointed my directory to "/home/.../q7root/bin/pip" and did an "ls". It shows a sub-directory with pip in it (or, I think, a link to it - I'm not the best at Unix). When I type "which pip" I get the path to this point ('q7root/pip'). bit if I just type "pip" at the CLI I get I get this error:
[![pip error][1]][1]
I have looked at my PATH, and this q7root/bin is the first place to look on the path. And, despite trying mightily with all the references people gave me, pip3 never gets installed.
But even pip is challenged. "which pip" points to this copy in the virtual environment site, but typing "pip" as a command tells me 'No module named pip.'
So pip seems to need more stuff installed (?), or there is some mess. Any advice?
Original Question:
At the suggestion of others working on what was a functional Django project, I upgraded to a more recent version of Ubuntu (18).
However, when I first try to run it it blows up at line 3 of the initial script module when asked to import django as a package.
I tried pip -r requirements.txt, but the system said pip was an unknown package. I dropped down and used apt to load pip onto my machine (sudo apt-get pip), then tried using pip itself (pip update pip) which failed.:
[![Pip load error message][2]][2]
I also tried pip install django, and got this:
[![django not found][3]][3]
I would have thought an OS upgrade would not require re-installing all currently installed packages (seems like a no-brainer to do the work of installing everything that had been installed). But right now I am terribly stuck...obviously, having 'pip' let's you (at least) have a basic CLI tool.
Any advice?
[1]: https://i.stack.imgur.com/OPfgc.png
[2]: https://i.stack.imgur.com/shLOc.png
[3]: https://i.stack.imgur.com/bEhDB.png
It depends on the version of python.
Python 3
sudo apt update
sudo apt install python3-pip
Python 2
sudo apt update
sudo apt install python-pip
How to Install Pip on Ubuntu 18.04
Start with a fresh Ubuntu install. I think you've run too many commands for your current setup to be reproduceable.
Install python3 and python3-venv.
sudo apt update
sudo apt install python3 python3-venv
Use the venv module to create the virtual env.
python3 -m venv myenv
source myenv/bin/activate
You now have access to pip in the venv.
It's OK to upgrade pip in the virtual env, I suggest you don't ever upgrade the system pip otherwise you might hit issues like this.
(myenv) python -m pip --version
(myenv) python -m pip install --upgrade pip
Now you can use pip to install your requirements in the virtual env.
(myenv) python -m pip install -r requirements.txt
In the above commands I've used python -m pip instead of pip. This is the recommended way, as it ensures that you are using the version of pip that matches python.
In the end, this was a state of deep computer confusion. I was already disk-limited so I bought a new computer, and this error did not recur with the same code being used.
I have a virtual machine under Hyper V that represents a cluster single-node of Hortonworks Data Platform with the following characteristics:
OS: centos 7.6.1810 minimal
python: 2.7.5
I installed pip package with the following command :
yum -y install python-pip
The installation is well finished, but when I want to check the version of pip pip -V it gives me this error : The folder you are executing pip from can no longer be found.
My folder /usr/local/bin/ does not contain any files or folders.
paths of python2.7 : /usr/bin/python2.7 /usr/bin/python2 /usr/bin/python
the cmd which python returns : /bin/python
paths of pip : /usr/bin/pip /usr/bin/pip2 /usr/bin/pip2.7
which -a pip
/bin/pip
/usr/bin/pip
I'm stuck thanks for helping me please.
Alternatively, kill your terminal, and start a new one.
Adding it as an answer since it worked. Pip requires a log out/log in to set environment variables.
Log out and log back in, try again and it seems to have worked.
Hi I hope someone can point me in the right direction.
I am trying to upload a django project which I have developed locally on my machine and now moved the project files to a server and am trying to install django on the server.
I have Python 2.7.5 installed and accessed the server remotely using ssh (putty) I can confirm Python is installed by running the command python --version
I don't have pip installed as when i run the command pip --version
I get following notification
-bash: pip: command not found
I am new to django and python so not sure what I should do to install both django and pip.
p.s In my requirements file and when working locally I have pip and django installed correctly and all working.
Ok, lets say you are already on your remote server. First thing to do is to install pip for your version of python. You can do this via:
sudo apt-get install python-pip
From now you have pip installed. Next thing to do is to install django globally in your system:
pip install django==1.11
Please note that django 1.11 is the last version that supports
python2
Next thing to do is to create django app:
django-admin startproject test_project
And the last thing is to install virtualenv
To install libraries for each of your django projects and keep them
separate
pip install virtualenv
Also note
If you have requirements.txt file with all libs, you can do something like this on your remote server:
pip install -r requirements.txt
That will automatically install all libraries at once
First you should understand which OS you're running:
uname -a
and:
lsb_release -a
When you find the OS version, you can easily follow this guide:
https://packaging.python.org/guides/installing-using-linux-tools/#installing-pip-setuptools-wheel-with-linux-package-managers
I have created a virtualenv in python 2.7 (Anaconda) on a dev machine and (after package installation) copied it to another windows machine in a PROD setting (no communication to outside). Executing any of the installed ".exe" entry points for a program in the virtualenv produces this error on the target machine however runs fine on the source machine:
(env) D:\app\pyvenv>env\Scripts\pip.exe
Fatal error in launcher: Unable to create process using '"'
The location of python installation on both machines is set to the same folder: C:\ProgramData\Anaconda2
Also see my additional notes at the bottom of this post. thanks
in my case, I previously changed the name of the python.exe executable to python3.exe so when I run:
virtualenv project1_env
it can't locate the python.exe if that was your case too .. just rename it again to python.exe and it should work.
In my case I solve by upgrading pip using following code in activate environment.
python -m pip install --upgrade pip
In my case I uninstalled venv and then installed it again and it worked.
pip uninstall virtualenv to uninstall it and use pip install virtualenv to install it again.
I had the same problem. Try making virtualenv with this command:
virtualenv --python C:\Path\To\Python\python.exe venv
Note that you should specify the path to your python installation folder after --python option.
python -m pip install --upgrade pip
Run this while in the venv. seems like a system change occured and reinstalling it restores it to default.
I'm trying to build a virtualenv that uses python27 in a virtualenv on an Amazon EC2. Research on the web indicated messing with the preinstalled Python26 is a bad idea so I wanted to work in a safe virtual env. Here are all of my commands starting from a fresh instance on EC2
sudo easy_install python27
sudo easy_install virtualenv
yum groupinstall "Development Tools"
mkdir virt_env
virtualenv -p python27 virt_env/py27
And this all seems to work great. When I activate my virtualenv Python27 is the default, and outside of it Python26 is the default. So far so good. Next I tried iPython in the virtualenv
source virt_env/py27/bin/activate
pip install ipython
This works great, again ipython is available in the virtualenv and not available outside of it. However when I go to install numpy in the virtualenv I get the follwing:
pip install numpy
// Lots of output that I won't paste all of it, main error below
SystemError: Cannot compile 'Python.h'. Perhaps you need to install python-dev|python-devel.
Not sure what I'm doing wrong because I've always installed numpy on virtualenv this way. Any help would be greatly appreciated thanks
EDIT: I've also tried using:
sudo yum install python-devel
in the virtualenv. Still no help
Was able to answer my own question. To install the python dev correctly I needed:
sudo yum install python27-devel