why can't I install flake8 by pip? - pip

I did like this
pip install flake8
then, terminal says that it has already installed and it is in
.pyenv/versions/anaconda3-2.1.0/lib/python3.4/site-packages. But,I did like this
which flake8
then, terminal says nothing. Why? I couldn't install that ?

It appears that your pip is using your pyenv installed version of python from anaconda. With that in mind, you should ensure that python points to that as well and do python -m flake8. That will let you run flake8.
Flake8 does not control where it's executable is installed to, but as long as you use the same python as is being used by pip, then you will still be able to run it.

Related

trying to set up a virtual environment, zsh: command not found: -m

I'm trying to set up a virtual environment. I have a Mac, using Mac OS Big Sur 11.1. I have installed the latest stable version of python, but when I enter this command into the terminal window
-m pip install pipenv pip --upgrade
I get the following error
zsh: command not found: -m
before, it would say
"No module named pip"
Do I have to install pip separately with
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
I thought pip was included by default when you install python? I think I might have pip because when I type
python3 -m pip
into the command line, I get a long list of commands (install packages, download packages, etc.) General options... Thus should I install pip? one person on reddit said,
Pip is not necessarily included with any version of Python. In many
distributions, it must be installed separately.
If python3 -m pip works, then you have a bad install, not a missing
one.
thus did I incorrectly install python? When I was installing it there was no option to
"add python to PATH"
Do I have to do this on a mac? If I input
python3 -V
in terminal, I get
Python 3.9.2
Thanks
i solved this by running,
pip3 install pip --upgrade

even after using pip update command, the version remains the same

I was just trying to download packages using pip in the terminal in pycharm and there was a notice from pip saying "You are using pip version 10.0.1, however, version 19.3.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command."
I ran the command but when I typed "pip -V" to check the version, it remained the same 10.0.1. And when I run the command, it says that pip is already up to date
How can solve this?
Your python and pip seem to point to different python versions. Check by typing which python or where python in the terminal.
To make sure they match, you can use
python -m pip install --upgrade pip (as you did) for upgrading
python -m pip install <package name> for installation

Py.test command not found, but library is installed

There are already two posts on stack overflow on this topic; however, none of them have resolved or addressed my specific situation.
I have installed pytest via pip install pytest. I am able to import the library in Python as well.
The problem is that when I try to use the py.test command in Terminal, I get py.test: command not found.
Does anyone have any insight as to why I am not able to use the command in the terminal?
EDIT: It even shows up as an installed package:
$ pip list
cycler (0.9.0)
matplotlib (1.5.1)
numpy (1.10.1)
pip (8.1.0)
py (1.4.31)
pyparsing (2.0.7)
pytest (2.9.0)
python-dateutil (2.4.2)
pytz (2015.7)
scipy (0.17.0)
setuptools (7.0)
six (1.10.0)
tensorflow (0.5.0)
vboxapi (1.0)
wheel (0.26.0)
using python -m pytest will work for you.
Or if you using virtual environment and installed pytest on virtualenv you should then run py.test alongside your virtual environment.
Check this website can be useful:http://pythontesting.net/framework/pytest/pytest-introduction/
I already had the latest version of pytest on macOS with Homebrew-installed Python 2.7 and this fixed it:
pip uninstall pytest
pip install pytest
Are you on a mac with homebrew by any chance?
I had the same issue and it basically came down to permissions/conflict with the mac os base installed python. pip install would not install or link stuff into /usr/local/bin (it happened with both virtualenv and pytest).
I uninstalled python 2.7 completely with homebrew (brew uninstall python).
Next, I reinstalled python with homebrew to fix pip (it was not a symlink in /usr/local/bin/pip where it should have been linked to Cellar) -- brew install python
Then I uninstalled pip with sudo -- sudo python -m pip uninstall pip to remove the pip owned by root
Now I uninstalled and reinstalled python with homebrew again to reinstall pip with the correct permissions brew uninstall python && brew install python
Next I fixed the python symlinks brew link python
Finally, pip install pytest worked! (and so did pip install virtualenv)
I found the information in the chosen answer from this post very helpful:
https://superuser.com/questions/915810/pip-not-working-on-hombrew-python-2-7-install.
If you're not on a mac, sorry for the noise...
I may be late, but while exploring this I noticed that this can be because the Scripts folder for python is not present in the PATH.
For me this is my scripts folder:
C:\Python38\Scripts\
If the path is a problem then running pip install pytest should actually you give you the warning with the path it was added to.
This should be present in the path. If on windows, edit the environment variables and this location to the PATH.
For me the path was incorrect because of an improper installation of python
I had the same issue. I had pytest v2.8.3 installed and the binary was on my path but under the name py.test. Upgrading to v3.0.3 added the regular pytest executable to the path.
I had the same problem. I have changed the Python installed folder permission to full access. And then uninstalled the pytest and installed again.
pip uninstall pytest
In my case, I had a similar issue in ubuntu 20.04. The below solution worked for me.
Cause: Shell remembers the previous version or previously used Path, hence we need to force the shell to 'forget' the old location - with -r
hash -r pytest
Then execute the tests it should work fine.
For MAC users:
Download python universal installer for mac:
https://www.python.org/ftp/python/3.10.5/python-3.10.5-macos11.pkg
Then try to install pytest module in terminal using this command:
pip install pytest
Hope this will fix the issue. Thanks!
use the command, pip install -U pytest and install it in your cmd prompt, it will solve the issueenter image description here
I used macbook air m2, and the way I deal with this problem is:
Command in terminal in macbook:
which pytest
/opt/anaconda3/bin/pytest -> my terminal shows this
Then you got the path of pytest, in the "Command", before "pytest", add its path and following with the path of python file you wanna test.
/opt/anaconda3/bin/pytest /Users/cindyng/Desktop/Testing.py
Done, and if you cannot find the path of python in macbook, "which python" also helps, and you can put it in "Home" and "Custom Python Builder".
Hope that helps, good luck!
I Fixed this issue via below steps.
1.First uninstall existing pytest.
2.Check python version.
3.then verify pytest version is supported with python version or not via github issue tracker.
4. via sudo install pytest
sudo pip install pytest
5. verify pytest version and insatlled correctly or not.
pip list
pytest --version
6.run any test using pytest test_abc.py
I encounter the same problem, python -m pytest works for me.

pip doesn't perform to install a module in Python 2.7, Windows 7

For Windows 7, x64, I'm trying to configure some libraries in Python. I use Python 2.7.11 and the Visual C++ Compiler Package for Python 2.7. When I try to install the library 'numpy-1.10.4+mkl-cp27-none-win_amd64.whl' using pip or easy_install, like:
C:\Python27\Scripts pip install D:\Downloads\numpy-1.10.4+mkl-cp27-none-win_amd64.whl
Nothing happens! I only see blank and can't do anything against it. After searching many pages about similar issues, I followed the instructions from this page:
http://arunrocks.com/guide-to-install-python-or-pip-on-windows/
Thus after installing pip and easy_install in the same path as Python and checking my environment variable the problem still persists..
Do anybody know what else I can do to use pip, or to install the wanted libraries? I'm really thankful for any idea!
You need to use the --use-wheel flag, and also have installed wheel. For example:
pip install wheel
pip install --use-wheel yourfile.whl
Your Windows Account doesnt have full persmissions. Maybe it says its Administrator, but something (ex Server) blocks some operations. I had the same issue at work, I couldnt install PIP but also XAMPP server on my PC.
However, I solved 1st issue - simply ran CMD as Admin, then went to
C:\Python27 and typed:
python.exe -m pip install MySQLdb
so PIP worked, and finally I updated it:
pip install --upgrade pip
P.S: I had 2 pythons 2.7 and 3.5 but did not reinstall or delete anything.

I don't know how to update my Python version to 3.4?

I'm on OSX, and I installed IDLE for Python 3.4. However, in Terminal my python -V and pip --version are both Python 2.7.
How do I fix this? I really have no idea how any of this works, so please bear with my lack of knowledge.
When you install Python3, you can use python3 to run python programs(or use a shebang). Python 3 also install pip. If you find your Python3 installed version of pip try to alias the pip command to the newer pip. Check this out for more info:
How to install pip for Python 3 on Mac OS X?
Try python3 or python3.4. It should print out the right version if correctly installed.
Python 3.4 already has pip with it. You can use python3 -m pip to access pip. Or python3 -m ensurepip to make sure that it's correctly installed.
I have found that making the 'python' alias replace the default version of python that the system comes with is a bad idea.
When you install a new version of python (3.4 for instance),
these two new commands are installed, specifically for the version you installed:
pip3.4
python3.4
If you're using an IDE that wants you to indicate which python version you are using the IDE will let you navigate to it in the Library folder
pip will still be for python2.7 after you download some other python version, as I think that's the current version osx comes installed with

Resources