How to Install virtualenv without pip? - python

I have a problem on pip.
As I use pyenv, using python version 3.7.x, there is no problem around pip.
$ /home/yuis/.pyenv/shims/pip --version
pip 19.2.3 from /home/yuis/.pyenv/versions/3.7.6/lib/python3.7/site-packages/pip (python 3.7)
But using python version 3.6.x, I get a result that saying the pip is located on "~/.local", but not on "~/.pyenv".
This is very bad for me. Because the version what I need now is 3.6.x.
This incomprehensive pip behavior continues if I install other python 3.6 version, so python 3.6.12 and 3.6.11 will show this same path.
I guess this bug is most probably because some kind of conflict from the locally installed python and pyenv installed one.
$ /home/yuis/.pyenv/shims/pip --version
WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip.
Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the underlying issue.
To avoid this problem you can invoke Python with '-m pip' instead of running pip directly.
pip 20.3.3 from /home/yuis/.local/lib/python3.6/site-packages/pip (python 3.6)
Now, I don't care much about pip anymore, because it seems an unsolvable issue. No time to waste. So now I want to try with virtualenv.
I need to install virtualenv first, because I can see this error.
$ virtualenv venv
pyenv: virtualenv: command not found
The `virtualenv' command exists in these Python versions:
3.5.10
3.7.6
Note: See 'pyenv help global' for tips on allowing both
python2 and python3 to be found.
But both of the followings didn't work.
pip install virtualenv
/home/yuis/.pyenv/shims/pip install virtualenv
python -m pip install virtualenv
Now I have no idea what is going on on my machine and how to solve this problem.

Have you tried python -m virtualenv .venv?

Try this maybe,
pip install git+https://github.com/pypa/virtualenv.git#main
You can visit this link for further details,
Also make sure your python & conda env are properly configured and added to PATH

Related

pip does not answer when used within pyenv

I have installed pyenv and pyenv-virtualenv using Homebrew (I am working on macOS Catalina 10.15.6).
I am running a pyenv environment with python version 3.7.8.
If I activate my pyenv-virtualenv, and then try to run some pip commands, the commands do not return anything. I just see the blinking cursor on the next line. For example:
$ pip install -r requirements
or
$ pip list
Though, when calling just pip, I have the help menu.
The configuration seems ok:
$ which pip
returns
Users/marie/.pyenv/shims/pip
Outside the pyenv, pip works normally.
The problem seems to come from specific versions of Python and pip. Indeed, moving to an older version of Python (Python 3.7.1) and pip (10.0.1) makes pip work fine.
But: Python 3.7.8 + pip 20 does not.
Any idea why this happens?
Try reinstalling pip. This is probably relevant to your situation: PyEnv Issue 1122 pyenv can't find pip
Try installing pip from scratch (from https://github.com/pypa/pip/issues/7620#issuecomment-576653578).
curl -fL https://bootstrap.pypa.io/get-pip.py | /Users/marie/.pyenv/shims/python -
If curl is not found, you can try with wget:
wget -O- https://bootstrap.pypa.io/get-pip.py | /Users/marie/.pyenv/shims/python -
I don't know why this would be happening with virtualenv. I guess there could be some problem with the package on homebrew. You can pip install virtualenv.

I'm confused about the difference between pip and pip3, in anaconda env

TL;DR: a package is installed under pip3, but it cannot be found under Python3. Why?
All of this is happening in my anaconda base environemnt:
So I've been struggling with tensorflow and its versions (another post coming up).Turns out version 2.1 is only available at pip and not with conda install. So after upgrading pip3 install --upgrade pip I install pip3 install tensorflow==2.1.0. I open Jupyer-Notebook afterwards, and turns out tensorflow is not installed(running Python3). I check from the terminal first for the version, and then to uninstall tensorflow. It is not installed under pip (as expected) but it is indeed installed under pip3. I also get this message when uninstalling via pip3:
"pip is being invoked by an old script wrapper. This will fail in a future version of pip.
Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the underlying issue.
To avoid this problem you can invoke Python with '-m pip' instead of running pip directly."
which might be related. I was under the impression that pip installs packages for the default python (3.7.4 in my case) but pip3 installs them only for Python3. What am I missing?
Thanks!
a package is installed under pip3, but it cannot be found under Python3. Why?
Because you have many different Pythons. pip doesn't install packages for all Pythons; pip3 doesn't install packages for Python3. They install packages for that particular Pythons they're running under. You cannot expect to install a package with one Python and import it in another eve if they're of the same version.
To see what Python is used with a particular pip see its shebang:
head -1 $(which pip)
head -1 $(which pip3)
If the shebang is #!/usr/bin/env python continue investigating with which python (or which python3).
Finding the Python run python -m site to see where from the packages are imported.

How to use pip with python3.5 after upgrade from 3.4?

I'm on Ubuntu and I have python2.7, (it came pre-installed) python3.4, (used before today) and python3.5, which I upgraded to today, installed in parallel. They all work fine on their own.
However, I want to use pip to install some packages, and I can't figure out how to do this for my 3.5 installation because pip installs for 2.7 and pip3 installs python 3.4 packages.
For instance, I have asyncio installed on 3.4, but I can't import it from 3.5. When I do pip3 install aysncio, it tells me the requirement is already satisfied.
I'm a bit of a newbie, but I did some snooping around install directories and couldn't find anything and I've googled to no avail.
I suppose you can run pip through Python until this is sorted out. (https://docs.python.org/dev/installing/)
A quick googling seems to indicate that this is indeed a bug. Try this and report back:
python3.4 -m pip --version
python3.5 -m pip --version
If they report different versions then I guess you're good to go. Just run python3.5 -m pip install package instead of pip3 install package to install 3.5 packages.
Another way would be to setup a virtual environment:
$ python3.4 -m venv envdir
$ source envdir/bin/activate
$ pip --version
Obviously, this won't install the packages globally and you'll have to source venv/bin/activate every time you wan to make use of it.

Why is PyCharm unable to find the correct verion of pip to install a Python module?

OSX: 10.9.5
PyCharm: 4.5
I am working on project in PyCharm IDE, using the 2.7.3 Python interpreter and need to import thepsycopg2 module. I tried to install the module with PyCharm, but it failed and asked me to do it manually:
Image of error message
So I typed that command in the bash shell, the module installed and now it shows up in the project interpreter 2.7.2 but not in 2.7.3 !!!!!
Maybe the pip version is too old? I upgraded pip from the bash shell: pip install --upgrade pip
python 2.7.2 shows version 7.1.0
python 2.7.3 shows version 1.5.6
You should open Preferenes > Project: (projectname) > Project Interpreter.
Choose the interpreter you want from the dropdown. If you have installed Python with Homebrew, as I have, then you maybe want to choose one of the python interpreters from the Cellars to ease usage of other packages you may have installed with Homebrew.
It might simply be that your system doesn't have pip installed, only pip3.
My system only showed me having pip3 not pip.
Use which pip3 and which pip to see if you have either.
I decided to update pip3, first trying pip3 install --upgrade pip3 which, oddly, returned: ERROR: No matching distribution found for pip3
Next, I ran pip3 install --upgrade pip and now PyCharm can install packages from the GUI.
You didn't specify what pip version you have. My guess is that the pip version is too old and PyCharm passing some flag which returns deprecation warning which cause it to fail. Try updating pip: pip install --upgrade pip

Installing python packages with multiple versions on OSX

I am attempting to install a package for python3.4 on Mac OSX 10.9.4. As you know, python ships with OSX, so when I installed python3.4 I was happy to find that it came with its own version of pip, that would install packages to it (installing pip on a mac with multiple versions of python will cause it to install on the system's python2.7.)
I had previously tried installing this package (https://pypi.python.org/pypi/chrome/0.0.1) with my first installation of pip (the one tied to python2.7) and found that it successfully installed on that version, but not on any others.
I ran an install with the new pip keyword for python3.4 (which when called by itself spits out the help page so i know it works) and it told me that the package was already installed and to try updating. The update revealed that I already had the most recent version. so I tried uninstalling it from just the python3.4 and reinstalling to no avail, and got the same results when uninstalling pip from python2.7 and reinstalling only on version 3.4.
I know that's a bit hard to follow but hopefully that makes sense.
I also reviewed the content here with no success.
RESOLVED:
while python did have a directory named the same as a directory it uses with packages, this was not the correct directory, for me it was in a subdirectory of library. while documentation said that referencing pip2 would cause the package to install on python3.4, this was false. however, referencing pip3.4 worked for me.
My suggestion is that you start using virtualenv.
Assuming you have 3.4 installed, then you should also have pyvenv. As for pip and 3.4, it should already be installed.
Using for example version 3.4 create your own virtual environment and activate it:
$ mkdir ~/venv
$ pyvenv-3.4 ~/venv/py34
$ source ~/venv/py34/bin/activate
$ deactive # does what is says...
$ source ~/venv/py34/bin/activate
$ pip install ... # whatever package you need
With version 2.7 first install virtualenv and then create your own virtual environment and activate it. Make sure that setuptools and pip are updated:
$ virtualenv-2.7 ~/venv/venv27
$ . ~/venv/venv27/bin/activate
$ pip install -U setuptools
$ pip install -U pip
$ pip install ... # whatever package you need

Categories