virtualenv binary not found after pip3 install - python

I'm working on macos and using python 3.8. I executed pip3 install virtualenv which seemed to run without errors. Now however, virtualenv on the command line comes back with a command not found error. No output from a which command either. Where would pip3 have placed the virtualenv binary?
Thanks!

Related

CMDER not finding sudo and pip commands

So I have been using regular windows command prompt and wanted to try using bash as most forums give commands in bash and it's a little cumbersome to try to find the translation to windows. Currently trying out Spotify API and I want to run a virtual environment.
I do the following windows command and everything runs fine:
[WINDOWS]
python -m pip install virtualenv
this, does not:
[BASH]
pip install virtualenv
and I get returned bash: pip: command not found
SO I go to install pip using sudo easy_install pip and get returned bash: sudo: command not found.
I am running CMDER as admin in bash so I thought ok, I will try easy_install pip and returned bash: easy_install: command not found. SO i went to the actual python directory and went to install pip again and no luck.
Any insight on how I can address this?
[Windows]]1[Bash]2
You can try to install pip by downloading the get-pip.py from here and then run it using python get-pip.py
After that
You might need to set your Environment Variable to include PIP in your path. you can use Environment Variables in Control Panel and add the path to System Variables.
I ran into this issue as well. Not sure what causes it, but switching to cmd.exe and running pip install ... worked without issue.

Pip Installation Python 3.6.1

I am a beginner in programming with Python. I have installed Python 3.6.1, and when I try to install pip (or any other package), this error appears (both in the command and shell):
install pip
^
SyntaxError: invalid syntax
I tried also with pip -m pip, but nothing, still the same error.
I would be very grateful if you could help me.
To install a Python package, you need to be in the command line as #MohideenibnMohammed suggested. You cannot install a package from within a Python script using pip.
You have installed Python 3.6.1 which will have pip already installed so you don't need to try and install that again.
Next, you need to make sure that Python is added to your PATH.
Open Start Menu and right click My Computer. Click on Advanced System Settings.
Click on Environment Variables
Find the system PATH variable and click Edit. You want to add Python to this PATH variable by adding exactly ;C:\Python36 (assuming that is where you installed Python)
Go back to the command line and type in pip install numpy (you can use pip3 instead of pip if you wish)
I think you are trying to use pip command in python console instead of terminal.
or check your command again .. pip install package
otherwise try this,
use pip3 install package to install instead of pip install package

Using pip on Windows installed with both python 2.7 and 3.5

I am using Windows 10. Currently, I have Python 2.7 installed. I would like to install Python 3.5 as well. However, if I have both 2.7 and 3.5 installed, when I run pip, how do I get the direct the package to be installed to the desired Python version?
You will have to use the absolute path of pip.
E.g: if I installed python 3 to C:\python35, I would use:
C:\> python35\Scripts\pip.exe install packagename
Or if you're on linux, use pip3 install packagename
If you don't specify a full path, it will use whichever pip is in your path.
Because usually i change my intepreter to run something(i got 2 diff projects with both 2 and 3), i use these solution:
Add path to the environment as usual (of course)
Rename ur python.exe , in my case i want to run python 3 using command python3 on my cmd. So i renamed my python.exe in python3.x directory with python3. Itll works with python 2 ofc.
Then to use pip in both python, i use this command.
python3 -m pip install 'somepackage'
and to run pip on python2
python -m pip install 'somepackage'
This is may not the best solution out there, but i like this one
** WINDOWS **
ref : https://datascience.com.co/how-to-install-python-2-7-and-3-6-in-windows-10-add-python-path-281e7eae62a
In my case, I have Python 2.7 and Python 3.4, with the Python Launcher for Windows.
This is the output when running this commands:
PS C:\> pip -V
pip 9.0.1 from c:\python27\lib\site-packages (python 2.7)
PS C:\> pip3 -V
pip 9.0.1 from C:\Python34\lib\site-packages (python 3.4)
I'll note that in my Python27\Scripts\ directory, I have pip.exe, pip2.exe and pip2.7.exe.
And in my Python34\Scripts\ directory, I have pip.exe, pip3.exe and pip3.4.exe.
So all of these .exe files help you when you have different versions of Python installed at the same time.
Of course, for this to work, you have to have the respective Scriptsdirectries in your Path system enviroment variable.
The answer from Farhan.K will work. However, I think a more convenient way would be to rename python35\Scripts\pip.exe to python35\Scripts\pip3.exe assuming python 3 is installed in C:\python35.
After renaming, you can use pip3 when installing packages to python v3 and pip when installing packages to python v2. Without the renaming, your computer will use whichever pip is in your path.
I would advise against ever calling any pip script directly (nor pip3, pip2.7.exe, anything like that).
Instead, a surefire way is to always prefer the explicit variant of calling pip's executable module for a specific Python interpreter:
path/to/pythonX.Y -m pip somecommand
path/to/venv/bin/python -m pip somecommand
C:\path\to\venv\Scripts\python.exe -m pip somecommand
There are many advantages to this, for example:
It is explicit for which Python interpreter the projects will be pip-installed (Python 2 or 3, inside the virtual environment or not, etc.)
For a virtual environment, one can pip-install (or do other things) without activating it: path/to/venv/bin/python -m pip install SomeProject
Under Windows this is the only way to safely upgrade pip itself path\to\venv\Scripts\python.exe -m pip install --upgrade pip
But yes, if all is perfectly setup, then python3 -m pip install SomeProject and pip3 install SomeProject should do the exact same thing, but there are way too many cases where there is an issue with the setup and things don't work as expected and users get confused (as shown by the many questions about this topic on this platform).
References
Brett Cannon's article "Why you should use python -m pip"
pip's documentation section on "Upgrading pip"
venv's documentation section on "Creating virtual environments": "You don’t specifically need to activate an environment [...]"
I ran across an issue with running pip with absolute path. This might be related to WinPython's installation routine and the order of installing Python 3.6 first, 2.7 second, or Python 3.6 being in the path.
No matter which pip was called, it was activating the 3.6 one:
λ C:\prog\WinPython-64bit-2.7.13.1Zero\python-2.7.13.amd64\Scripts\pip2.exe --version
pip 9.0.1 from C:\prog\WinPython-64bit-3.6.1.0Zero\python-3.6.1.amd64\lib\site-packages (python 3.6)
What finally did the trick was calling pip as a module of the respective python binary:
λ C:\prog\WinPython-64bit-2.7.13.1Zero\python-2.7.13.amd64\python.exe -m pip --version
pip 9.0.1 from C:\prog\WinPython-64bit-2.7.13.1Zero\python-2.7.13.amd64\lib\site-packages (python 2.7)
Hope that might help someone with similar issues.
I tried many things , then finally
pip3 install --upgrade pip worked for me as i was facing this issue since i had both python3 and python2.7 installed on my system.
mind the pip3 in the beginning and pip in the end.
And yes you do have to run in admin mode the command prompt and make sure if the path is set properly.
1-open command prompt and change direction using the command cd C:\Python35\Scripts
2- write the command pip3 install --upgrade pip
3- close the command prompt and reopen it again to return to the default direction and use the command pip3.exe install package_name to install any package you want

Pip suddenly using wrong version of Python

Having a weird problem with pip on os x.
As far as I can recall (and a quick look at my .bash_history seems to confirm) I have not made any recent changes to my configuration. Alas, the pip command seems to be suddenly using a different version of python than it was previously. Up until now I was using the command pip to manage my python2 libraries and pip3 to manage by python3 libraries. Suddenly, any attempts at running pip install fails with errors like missing parenthesis around print statements.
Here is the result of a few commands I attempted to figure out the problem:
which pip > /usr/local/bin/pip
which pip3 > /usr/local/bin/pip3
which python > /usr/local/bin/python
python version > Python 2.7.11
pip --version > pip 8.1.1 from /usr/local/lib/python3.5/site-packages (python 3.5)
So for some reason the pip command seems to be running from the PyPi2 database but in python3 now? Any ideas how to fix this?
I run with multiple Python versions and thus multiple pip versions as well.
Everytime, however, you update pip, you'll replace the standard pip command with the version you updated. So even pip3 install --upgrade pip will put a /usr/local/bin/pip in your system, messing up the Python 2 version.
Instead, I run pip as an (executable) module:
python3 -m pip search <package>
or
python2 -m pip search <package>
or even
python3.5 -m pip search <package>
This guarantees that your pip version always matches the Python version you want to use it for. It's somewhat longer to type, but I prefer the expliciteness of it (which, I guess, follows the Zen of Python).
Note that updating pip:
python3.5 -m pip install --upgrade pip
will still install a Python 3.5 version in /usr/local/bin/pip, but I'm simply ignoring that. Just beware of (shell) scripts that execute pip directly.
Find absolute path to Python you'd like to use:
which python
Open your default pip executable script:
vi $(which pip)
You will see a shebang line at the top which may point to wrong Python (i had that once too).
Point to the Python you want (see step 1), e.g.:
#!/usr/local/bin/python3.7
Try setting aliases by running the following commands in Terminal,
alias pip="/usr/local/bin/pip"
alias pip2="/usr/local/bin/pip"
alias pip3="/usr/local/bin/pip3"
If this solves your problem then you need to add the aliases in your bash profile.
Look How do I create a Bash alias? for more info.
Alternatively, you have to reinstall pip using python2 get-pip.py first and then python3 get-pip.py get-pip.py can be downloaded here https://bootstrap.pypa.io/get-pip.py
I had exactly the same problem!
I reinstall python2 by brew brew reinstall python#2
after reinstall, pip install packagename works!
None of these worked for me so what I did was navigate to
C:\Users(User)\AppData\Local\Programs\Python\
and deleted all the old python versions I wasn't using. (Worked)

Did I install pip correctly?

I'm new to python and the tutorial I'm using suggested for me to install four important packages (distribute, pip, nose and virtual env).
I've installed the first two using setup.py in Windows PowerShell
Problem is I can't figure out how to use pip. I've tried doing commands for pip in the cmd, python idle shell and powershell. All of them return something similar to pip is not defined or there is a syntax error
Here's what i type which results to syntax error
pip freeze
pip list --outdated
Anyone know if I've done something wrong installing pip?
Notes:
I'm using Windows 7
I've checked the Python2.7 directory and pip is in the Scripts folder.
I've also used help("modules") in the Python Idle shell and it lists pip in the modules
To add an answer to this question (it was provided in the comments by Joran Beasley), the issue here was that pip installs to the python/Scipts directory, but that was not in the path by default on Windows. Adding C:\Python27\Scripts to the path fixed the issue. This answer describes adding a directory to the path on Windows 7.
if you've ubuntu you have just to install the pip with aptget
sudo apt-get install python-pip

Categories

Resources