Related
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.
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.
when I try to install TensorFlow by cloning from Git, I run into the error "no module named copyreg," so I tried installing using a virtualenv. However, I then run into this error:
pip install https://storage.googleapis.com/tensorflow/mac/tensorflow-0.5.0-py2-none-any.whl
tensorflow-0.5.0-py2-none-any.whl is not a supported wheel on this platform.
I don't see this under the common problems section.
I am using OS X v10.10.5 (Yosemite) and Python 3.4.3, but I also have Python 2.7 (I am unsure if pip differentiates between these or how to switch between them).
I too got the same problem.
I downloaded get-pip.py from https://bootstrap.pypa.io/get-pip.py and then ran python2.7 get-pip.py for installing pip2.7.
And then ran the pip install command with python2.7 as follows.
For Ubuntu/Linux:
python2.7 -m pip install https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.5.0-cp27-none-linux_x86_64.whl
For Mac OS X:
python2.7 -m pip install https://storage.googleapis.com/tensorflow/mac/tensorflow-0.5.0-py2-none-any.whl
This should work just fine as it did for me :)
I followed these instructions from here.
After activating the virtualenv, be sure to upgrade pip to the latest version.
(your_virtual_env)$ pip install --upgrade pip
And now you'll be able to install TensorFlow correctly (for Linux):
(your_virtual_env)$ pip install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.7.0-py2-none-linux_x86_64.whl
I was trying to do the Windows-based install and kept getting this error.
It turns out you have to have Python 3.5.2. Not 2.7, not 3.6.x-- nothing other than 3.5.2.
After installing Python 3.5.2, the pip install worked.
Make sure that the wheel is, well, supported by your platform. Pip uses the wheel's filename to determine compatibility. The format is:
tensorflow-{version}-{python version}-none-{your platform}.whl
I didn't realize that x86_64 refers to x64, I thought it meant either x86 or x64, so I banged my head against this futilely for some time. TensorFlow is not available for 32-bit systems, unless you want to compile it yourself.
It seems that TensorFlow only works on Python 3.5 at the moment. Try to run this command before running the pip install
conda create --name tensorflow python=3.5
After this, run the following lines:
For CPU:
pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-1.1.0-cp35-cp35m-win_amd64.whl
For GPU:
pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/windows/gpu/tensorflow_gpu-1.1.0-cp35-cp35m-win_amd64.whl
It should work like a charm.
On Windows 10, with Python 3.6.X version I was facing the same. Then after checking deliberately, I noticed I had Python-32 bit installation on my 64-bit machine. Remember TensorFlow is only compatible with a 64-bit installation of Python. Not 32 bit of Python
If we download Python from python.org, the default installation would be 32 bit. So we have to download the 64 bit installer manually to install Python 64 bit. And then add
C:\Users<username>\AppData\Local\Programs\Python\Python36
C:\Users<username>\AppData\Local\Programs\Python\Python36\Scripts
Then run gpupdate /Force on the command prompt. If the Python command doesn’t work for 64 bit, restart your machine.
Then run the Python interpreter on the command prompt. It should show 64 bit
python
Python 3.6.3 (v3.6.3:2c5fed8, Oct 3 2017, 18:11:49) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
Then run the below command to install the TensorFlow CPU version (recommended)
pip3 install --upgrade tensorflow
The pip wheel file contains the Python version in its name (cp34-cp34m). If you download the .whl file and rename it to say py3-none or instead, it should work. Can you try that?
The installation won't work for Anaconda users that choose Python 3 support, because the installation procedure is asking to create a Python 3.5 environment and the file is currently called cp34-cp34m. So renaming it would do the job for now.
sudo pip3 install --upgrade https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow-0.7.0-cp34-cp34m-linux_x86_64.whl
This will produce the exact error message you got above. However, when you will download the file yourself and rename it to "tensorflow-0.7.0-py3-none-linux_x86_64.whl", then execute the command again with the changed filename, it should work fine.
For Windows 10 64 bit:
I have tried all the suggestions here, but finally I got it running as follows:
Uninstall all current versions of Python
Remove all Python references in the PATH system and user environment variables
Download the latest 64-bit version of Python 3.8: Python 3.8.7 currently, not the latest 3.9.x version which is the one I was using, and not 32 bit.
Install with all options selected, including pip, and including the PATH environment variable
pip install tensorflow (in an administrator CMD prompt)
Upgrade pip if prompted (optional)
Actually, you can use Python 3.5.*.
I successfully solved this problem with Python 3.5.3. Modify the Python version to 3.5.* in Conda. See Managing Python.
Then go to https://www.tensorflow.org/install/install_windows, and repeat from "Create a Conda environment named tensorflow by invoking the following command" bla, bla...
Maybe you are installing the wrong pre-build binary?
Check on https://github.com/lakshayg/tensorflow-build
For my Coffee Lake processor on Ubuntu 18.04 (Bionic Beaver) the download URL was:
https://github.com/lakshayg/tensorflow-build/releases/download/tf1.12.0-ubuntu18.04-py2-py3/tensorflow-1.12.0-cp36-cp36m-linux_x86_64.whl
pip install --ignore-installed --upgrade <PATH>
resolved the issue for me.
I was trying to install from source and got that error. (Why would a wheel built on this machine not be compatible with it?)
For me, the tag --ignore-installed made all the difference.
pip install --ignore-installed /tmp/tensorflow_pkg/tensorflow-1.8.0-cp36-cp36m-linux_x86_64.whl
worked, while
pip install /tmp/tensorflow_pkg/tensorflow-1.8.0-cp36-cp36m-linux_x86_64.whl
threw the abovementioned error.
Context: Conda environment; it might have been a problem specific to this
I was trying to install CPU TensorFlow on Ubuntu 18.04 (Bionic Beaver), and the best way (for me...) I found for it was using it on top of Conda, for that:
To create a Conda ‘tensorflow’ environment. Follow How to Install Anaconda on Ubuntu 18.04
After all is installed, see Getting started with conda. And use it according to Managing environments
conda create --name tensorflow
source activate tensorflow
pip install --upgrade pip
pip uninstall tensorflow
For CPU: pip install tensorflow-cpu, for GPU: pip install tensorflow
pip install --ignore-installed --upgrade tensorflow
Test TF E.g. on 'Where' with:
python
import tensorflow as tf
>>> tf.where([[True, False], [False, True]])
Expected result:
<tf.Tensor: shape=(2, 2), dtype=int64, numpy=
array([[0, 0],
[1, 1]])>
After the Conda upgrade, I got:
DeprecationWarning: 'source deactivate' is deprecated. Use 'conda deactivate'.
So you should use:
‘conda activate tensorflow’ / ‘conda deactivate’
I faced the same issue and tried all the solutions that folks suggested here and other links (like Platform not supported for TensorFlow on Ubuntu 14.04.2).
It was so frustrating because using print(wheel.pep425tags.get_supported()) I could see that my Ubuntu supported ('cp37', 'cp37m', 'linux_x86_64') and that was exactly what I was trying to install (from https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.14.0-cp37-cp37m-linux_x86_64.whl).
What at the end fixed it was to simply download the package first and then
pip install tensorflow-1.14.0-cp37-cp37m-linux_x86_64.whl
It means that the version of your default Python interpreter (python -V) and the version of your default pip (pip -V) do not match. You have built TensorFlow with your default Python interpreter and trying to use a different pip version to install it.
In Mac, delete /usr/local/bin/pip and rename (copy) pipx.y (whatever x.y version that matches your Python version) to pip in that folder.
This worked for me.
system requirement Python 3.7–3.10
macOS 10.12.6 (Sierra) or later (no GPU support)
pip install tensorflow-macos
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
I'm having serious difficulty installing Scipy with pip on Mountain Lion.
I've tried:
sudo pip install -e git+https://github.com/scipy/scipy#egg=scipy-dev
As suggested in various places on the web.
This leads to errors like:
ld: library not found for -lgcc
lipo: can't figure out the architecture type of: /var/tmp//ccC2HLVs.out
and several warnings (I assume not serious) before the errors.
Does anybody have any suggestions?
Scipy is also available now via a homebrew tap. If you have homebrew installed:
brew tap samueljohn/python
brew install scipy
See more info here: homebrew-python
Pip has difficulties with scipy on OS X in general. It is not trivial to install from the sources, so I advise against it. In OS X you have a few better options:
Scipy superpack, a bunch of precompiled binaries
Enthought Canopy (free or another) has already everything you'll need (numpy, scipy, matplotlib, etc.)
Anaconda, a free scientific python distribution with probably all the packages you'll ever need.
MacPorts, a comprehensive and flexible package manager that allows you to install and maintain a python distribution
Homebrew, another popular package manager for OS X
Here is what worked for me for pip installing matplotlib and scipy inside a virtual environment (Mac OS X 10.9.2 Mavericks):
# See George's answer above
brew update
brew upgrade
brew install gfortran
# See http://www.scipy.org/scipylib/building/macosx.html (the link Nathan Gould posted above)
export CXX=g++-5.1
export CC=gcc-5.1
export FFLAGS=-ff2c
sudo ln -s /usr/bin/gcc /usr/bin/gcc-5.1
sudo ln -s /usr/bin/g++ /usr/bin/g++-5.1
pip install matplotlib
pip install scipy
matplot lib installed quickly, but scipy took a long time.
Just to add to what #Anton I. Sipos said. I had the Enthought package installed but had issues with upgrading it, so I decided to go with a clean install using Homebrew. Unfortunately just performing the tap and install didn't work well for me. So on searching a bit I found an issue on GitHub that samualjohn addressed and worked for me:
brew remove python
rm -rf /Library/Python/2.7/site-packages # it's save to delete this!
brew install python
pip install nose
brew install numpy
brew install scipy
The problem was clearly conflicts in the site-packages that the Enthought uninstall instructions did not cover.
NOTE: I had to install matplotlib with pip.
I had similar issues installing scipy on OSX 10.9 Mavericks as well. What solved it for me is the following:
sudo pip list
was showing numpy, thus I did:
sudo pip install --upgrade numpy
Afterwards
brew list
was showing gfortran. I made sure I had the latest version by
brew update
brew upgrade
but
sudo pip install scipy
was failing with a weird fortran error.
Thus I uninstalled it and reinstalled it
sudo brew install gfortran
sudo brew uninstall gfortran
and to my great surprise
sudo pip install scipy
worked after that.
I recently also had trouble getting scipy to install on a virtualenv. My problem was that gfortran was not seen properly. I used macports sudo port install gcc48 and created a symlink to just gfortran by:
sudo ln -s /opt/local/bin/gfortran-mp-4.8 /opt/local/bin/gfortran
After that, pip install scipy worked without any errors on my virtualenv.
Installing scipy on Mac OS X with pip is possible! You will need the right C and Fortran compilers on your system to set up scipy. This page should help you:
http://www.scipy.org/scipylib/building/macosx.html
Once you have done that, you should be able to install with pip install scipy.
As an additional troubleshooting note, you might need to create a symlink to your compiler so that the setup process can find it. A previous poster #biophetik gave an example of how to do this.
Also, I already had numpy installed in my virtual environment when I installed scipy. I'm not positive whether/how one depends on the other.
On Mavericks the following works (might also work on other versions):
If you haven't already, install pip
sudo easy_install pip
Then install/update scipy
sudo pip install scipy -U
For some reason pip installs scipy to
/Library/Python/2.7/site-packages/
and does not remove the older version in
/System/Library/Frameworks/Python.framework/Versions/2.7//Extras/lib/python/scipy/
So just remove the old version and it works. Print the version number:
python -c "import scipy; print scipy.__version__"
I tryed everything: pip, macports,easy_install,... with Mac OS El Captain. The only thing that worked for me was brew:
$ brew install scipy
After that, it will ask you to follow the instructions bellow:
$ brew link --overwrite numpy
$ mkdir -p /Users/adrieljr/Library/Python/2.7/lib/python/site-packages
$ echo 'import sys; sys.path.insert(1, "/usr/local/lib/python2.7/site-packages")' >> /Users/adrieljr/Library/Python/2.7/lib/python/site-packages/homebrew.pth