Starting with python3.8, I noticed that the wheel package seems to be required to pip install packages without errors (at least they look like errors, but behave like warnings).
Note: in all of my examples, I am cleaning up in between by deactivating my environment, removing the environment, and clearing my pip cache:
deactivate
rm test_env/ -rf
rm ~/.cache/pip/ -rf
Example 1: The problem
python3.8 -m venv test_env
source test_env/bin/activate
pip install markuppy
I get the following output:
Collecting markuppy
Downloading MarkupPy-1.14.tar.gz (6.8 kB)
Building wheels for collected packages: markuppy
Building wheel for markuppy (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: /home/k/test_env/bin/python3.8 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-tfm9bgxv/markuppy/setup.py'"'"'; __file__='"'"'/tmp/pip-install-tfm9bgxv/markuppy/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-cpx9gxcn
cwd: /tmp/pip-install-tfm9bgxv/markuppy/
Complete output (6 lines):
usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
or: setup.py --help [cmd1 cmd2 ...]
or: setup.py --help-commands
or: setup.py cmd --help
error: invalid command 'bdist_wheel'
----------------------------------------
ERROR: Failed building wheel for markuppy
Running setup.py clean for markuppy
Failed to build markuppy
Installing collected packages: markuppy
Running setup.py install for markuppy ... done
Successfully installed markuppy-1.14
It errored because there is no wheel package installed. This has been addressed in other posts on SO.
Example 2: Fixing the problem by installing wheel into the venv
If I install the wheel package directly after creating a new venv, this does not happen:
python3.8 -m venv test_env
source test_env/bin/activate
pip install wheel
pip install markuppy
Output:
Collecting markuppy
Using cached MarkupPy-1.14.tar.gz (6.8 kB)
Building wheels for collected packages: markuppy
Building wheel for markuppy (setup.py) ... done
Created wheel for markuppy: filename=MarkupPy-1.14-py3-none-any.whl size=7413 sha256=52b3e5c3e317ae21724acd871fe3deb85dde9df305b20d16f2c5592c43b11e91
Stored in directory: /home/k/.cache/pip/wheels/95/13/60/31c9d5f4cd012e491aeac154ef8b0ec964916523623eb02f0b
Successfully built markuppy
Installing collected packages: markuppy
Successfully installed markuppy-1.14
This also works given a requirements.txt file.
requirements.txt:
markuppy
python3.8 -m venv test_env
source test_env/bin/activate
pip install wheel
pip install -r requirements.txt
Output:
Collecting markuppy
Using cached MarkupPy-1.14.tar.gz (6.8 kB)
Building wheels for collected packages: markuppy
Building wheel for markuppy (setup.py) ... done
Created wheel for markuppy: filename=MarkupPy-1.14-py3-none-any.whl size=7413 sha256=52b3e5c3e317ae21724acd871fe3deb85dde9df305b20d16f2c5592c43b11e91
Stored in directory: /home/k/.cache/pip/wheels/95/13/60/31c9d5f4cd012e491aeac154ef8b0ec964916523623eb02f0b
Successfully built markuppy
Installing collected packages: markuppy
Successfully installed markuppy-1.14
Example 3: Adding the wheel package to requirements.txt does not help
It's important to know that if you place the wheel package into the requirements.txt file, and do not install it separately, you get the same problem as in Example 1:
requirements.txt:
wheel
markuppy
python3.8 -m venv test_env
source test_env/bin/activate
pip install -r requirements.txt
Output:
Collecting wheel
Downloading wheel-0.37.0-py2.py3-none-any.whl (35 kB)
Collecting markuppy
Downloading MarkupPy-1.14.tar.gz (6.8 kB)
Building wheels for collected packages: markuppy
Building wheel for markuppy (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: /home/k/test_env/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-z7cqzaej/markuppy/setup.py'"'"'; __file__='"'"'/tmp/pip-install-z7cqzaej/markuppy/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-kw3_8ayt
cwd: /tmp/pip-install-z7cqzaej/markuppy/
Complete output (6 lines):
usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
or: setup.py --help [cmd1 cmd2 ...]
or: setup.py --help-commands
or: setup.py cmd --help
error: invalid command 'bdist_wheel'
----------------------------------------
ERROR: Failed building wheel for markuppy
Running setup.py clean for markuppy
Failed to build markuppy
Installing collected packages: wheel, markuppy
Running setup.py install for markuppy ... done
Successfully installed markuppy-1.14 wheel-0.37.0
Wheel installed properly, but was not there in time to install the markuppy package.
Example 4: Installing wheel at the system level does not help
If I install the wheel package directly into the system itself, the venv that was created does not have access to it, so I get the same result as in Example 1.
sudo apt install python3-wheel
python3.8 -m venv test_env
source test_env/bin/activate
pip install markuppy
Output:
Collecting markuppy
Downloading MarkupPy-1.14.tar.gz (6.8 kB)
Building wheels for collected packages: markuppy
Building wheel for markuppy (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: /home/k/test_env/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-5xkssq1l/markuppy/setup.py'"'"'; __file__='"'"'/tmp/pip-install-5xkssq1l/markuppy/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-aunof5xf
cwd: /tmp/pip-install-5xkssq1l/markuppy/
Complete output (6 lines):
usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
or: setup.py --help [cmd1 cmd2 ...]
or: setup.py --help-commands
or: setup.py cmd --help
error: invalid command 'bdist_wheel'
----------------------------------------
ERROR: Failed building wheel for markuppy
Running setup.py clean for markuppy
Failed to build markuppy
Installing collected packages: markuppy
Running setup.py install for markuppy ... done
Successfully installed markuppy-1.14
Example 5: Installing wheel at the system level and granting venv access to system site packages works
If I install wheel at the system level, then grant my venv access to system site packages (note the flag on the venv command) when I create it, then this issue does not happen.
sudo apt install python3-wheel
python3.8 -m venv test_env --system-site-packages
source test_env/bin/activate
pip install markuppy
Output:
Collecting markuppy
Downloading MarkupPy-1.14.tar.gz (6.8 kB)
Building wheels for collected packages: markuppy
Building wheel for markuppy (setup.py) ... done
Created wheel for markuppy: filename=MarkupPy-1.14-py3-none-any.whl size=7414 sha256=cefe8d9f20cecaf72253cab1e18acbdcb6d30827d7a3fd5a74bbef4935bc2e44
Stored in directory: /home/k/.cache/pip/wheels/95/13/60/31c9d5f4cd012e491aeac154ef8b0ec964916523623eb02f0b
Successfully built markuppy
Installing collected packages: markuppy
Successfully installed markuppy-1.14
The obvious downside to this approach is that it breaks isolation between your project's venv and the python packages installed on the system itself.
Example 6: None of this happens in Python3.7
python3.7 -m venv test_env
source test_env/bin/activate
pip install -U pip
pip install markuppy
Output:
Collecting markuppy
Downloading MarkupPy-1.14.tar.gz (6.8 kB)
Using legacy 'setup.py install' for markuppy, since package 'wheel' is not installed.
Installing collected packages: markuppy
Running setup.py install for markuppy ... done
Successfully installed markuppy-1.14
Although it does provide a warning that pip used setup.py install in lieu of wheel.
The Question
How are we supposed to deal with this wheel package? It seems that it's expected that we all have this package installed in most (all?) environments, but the environment tooling in the standard library does not automatically provide it.
I like the idea of keeping my project environments completely isolated from the system python environment, so it looks like the only options that I can see are:
Manually install the wheel package immediately after creating a new venv.
Using another tool besides venv to manage environments.
When setting up a venv, before running anything else, just run pip install --upgrade pip wheel first. This was a good practice anyhow to insure you're using the latest version of pip to resolve your dependencies, hence the warning:
WARNING: You are using pip version 22.0.4; however, version 22.2.2 is available.
You should consider upgrading via the '/home/user/tmp/test_env/bin/python3 -m pip install --upgrade pip' command.
It does seem wheel is no longer included by default, as I was able to replicate on 3.10 as well. Specifying --system-site-packages to use system wheel would be expected, the whole point of venv is to avoid touching the system python. Not being used during a requirements.txt install also makes sense, as it's unlikely any of the packages have wheel listed as a dependency, so it's probably being installed in parallel.
Related
unable to find the fix for it. Here is the output from the console. I have tried using different python interpreters and also downloaded mysql
pip
The following command was executed:
pip install mysqlclient==2.1.0
The exit code: 1
The error output of the command:
Collecting mysqlclient==2.1.0
Using cached mysqlclient-2.1.0.tar.gz (87 kB)
Building wheels for collected packages: mysqlclient
Building wheel for mysqlclient (setup.py): started
Building wheel for mysqlclient (setup.py): finished with status 'error'
Running setup.py clean for mysqlclient
Failed to build mysqlclient
Installing collected packages: mysqlclient
Running setup.py install for mysqlclient: started
Running setup.py install for mysqlclient: finished with status 'error'
ERROR: Command errored out with exit status 1:
command: 'D:\Nutrition\Source Code\context\venv\Scripts\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\gunot\\AppData\\Local\\Temp\\pip-install-4xfatye_\\mysqlclient_5cf00f5723004ef1a4f6fe1a1f9673d1\\setup.py'"'"'; __file__='"'"'C:\\Users\\gunot\\AppData\\Local\\Temp\\pip-install-4xfa... (show balloon)
I was trying to install dryscrape and when i write !pip install dryscrape
in google colab i get the following output:
Collecting dryscrape
Downloading https://files.pythonhosted.org/packages/b5/75/c45f796ec5bc7f98c38b9ae425390ef5f4a76153c8b5af946adb97e7e622/dryscrape-1.0.tar.gz
Collecting webkit_server>=1.0
Downloading https://files.pythonhosted.org/packages/29/f2/f4f454cccde75e95359e91fa58f14497350dc97e58534f9003c77eca3dff/webkit-server-1.0.tar.gz (41kB)
|████████████████████████████████| 51kB 2.5MB/s
Requirement already satisfied: lxml in /usr/local/lib/python3.7/dist-packages (from dryscrape) (4.2.6)
Collecting xvfbwrapper
Downloading https://files.pythonhosted.org/packages/57/b6/4920eabda9b49630dea58745e79f9919aba6408d460afe758bf6e9b21a04/xvfbwrapper-0.2.9.tar.gz
Building wheels for collected packages: dryscrape, webkit-server, xvfbwrapper
Building wheel for dryscrape (setup.py) ... done
Created wheel for dryscrape: filename=dryscrape-1.0-cp37-none-any.whl size=5440 sha256=8e8469df960b731a8cb688d85b0cd4abcdd0aa4bcf5805d817af8e91b57091c1
Stored in directory: /root/.cache/pip/wheels/d5/7e/24/0b5b37166c524082a6fb722bc14c6f885ebb7fcfc7e1563f3e
Building wheel for webkit-server (setup.py) ... error
ERROR: Failed building wheel for webkit-server
Running setup.py clean for webkit-server
Building wheel for xvfbwrapper (setup.py) ... done
Created wheel for xvfbwrapper: filename=xvfbwrapper-0.2.9-cp37-none-any.whl size=5009 sha256=0df17305d7fbff2973dddb1560c1e232f19fcc2a73be1dca2ed2a00d1a2c50f5
Stored in directory: /root/.cache/pip/wheels/10/f2/61/cacfaf84b352c223761ea8d19616e3b5ac5c27364da72863f0
Successfully built dryscrape xvfbwrapper
Failed to build webkit-server
Installing collected packages: webkit-server, xvfbwrapper, dryscrape
Running setup.py install for webkit-server ... error
ERROR: Command errored out with exit status 1: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-irrofp8e/webkit-server/setup.py'"'"'; file='"'"'/tmp/pip-install-irrofp8e/webkit-server/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' install --record /tmp/pip-record-ufv_nemh/install-record.txt --single-version-externally-managed --compile Check the logs for full command output.
I tried installing from the github repository and i get the same output when i write !pip install -r requirements.txt, i was using the offical documentation.
Seeing to the logs error is regarding the webkit-server library and seeing in the GitHub issues of webkit-server the library came to the pull request, which helped me install webkit-server and then install dryscrape follow the below commands to install it in your Colab.
Command 1:
!pip install git+https://github.com/niklasb/webkit-server.git#refs/pull/35/head
Command 2:
!pip install dryscrape
This will successfully install dryscrape.
Output:
Let me know if you have any questions :)
I try to install watchman on Ubuntu 20.04.01:
guettli#yoga15:~/tmp$ python3 -m venv pywatchman-test
guettli#yoga15:~/tmp$ cd pywatchman-test
guettli#yoga15:~/tmp/pywatchman-test$ . bin/activate
(pywatchman-test) guettli#yoga15:~/tmp/pywatchman-test$ pip install pywatchman
Fails:
Collecting pywatchman
Using cached pywatchman-1.4.1.tar.gz (29 kB)
Building wheels for collected packages: pywatchman
Building wheel for pywatchman (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: /home/guettli/tmp/pywatchman-test/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-on_zbadt/pywatchman/setup.py'"'"'; __file__='"'"'/tmp/pip-install-on_zbadt/pywatchman/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-9np2rv_b
cwd: /tmp/pip-install-on_zbadt/pywatchman/
Complete output (6 lines):
usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
or: setup.py --help [cmd1 cmd2 ...]
or: setup.py --help-commands
or: setup.py cmd --help
error: invalid command 'bdist_wheel'
----------------------------------------
ERROR: Failed building wheel for pywatchman
Running setup.py clean for pywatchman
Failed to build pywatchman
Installing collected packages: pywatchman
Running setup.py install for pywatchman ... done
Successfully installed pywatchman-1.4.1
I found a way to solve this: If I uninstall pywatchman and install wheel it works fine.
I would like to create a patch for watchman, so that this works right of the box.
How could this be solved, so that in future this does not happen any more?
Related: https://github.com/facebook/watchman/issues/876
Running
pip install wheel
or
pip3 install wheel
or
python3 -m pip install wheel
solved the issue for me
Hi I've been trying to install cryptography into my venv, but my venv doesn't find 'bdist_wheel'. (Python3)
I installed wheel like so pip install --user wheel and tried to install cryptography pip install --user cryptography I get back this error error: invalid command 'bdist_wheel' during the setup.py script. I've also tried pip install --upgrade setuptools
What am I missing? I've seen similar QAs in here but didn't seem to occur inside a venv.
pip install --user cryptography
Collecting cryptography
Using cached https://files.pythonhosted.org/packages/ec/b2/faa78c1ab928d2b2c634c8b41ff1181f0abdd9adf9193211bd606ffa57e2/cryptography-2.2.2.tar.gz
Collecting idna>=2.1 (from cryptography)
Using cached https://files.pythonhosted.org/packages/27/cc/6dd9a3869f15c2edfab863b992838277279ce92663d334df9ecf5106f5c6/idna-2.6-py2.py3-none-any.whl
Collecting asn1crypto>=0.21.0 (from cryptography)
Using cached https://files.pythonhosted.org/packages/ea/cd/35485615f45f30a510576f1a56d1e0a7ad7bd8ab5ed7cdc600ef7cd06222/asn1crypto-0.24.0-py2.py3-none-any.whl
Collecting six>=1.4.1 (from cryptography)
Using cached https://files.pythonhosted.org/packages/67/4b/141a581104b1f6397bfa78ac9d43d8ad29a7ca43ea90a2d863fe3056e86a/six-1.11.0-py2.py3-none-any.whl
Collecting cffi>=1.7 (from cryptography)
Using cached https://files.pythonhosted.org/packages/59/cc/0e1635b4951021ef35f5c92b32c865ae605fac2a19d724fb6ff99d745c81/cffi-1.11.5-cp35-cp35m-manylinux1_x86_64.whl
Collecting pycparser (from cffi>=1.7->cryptography)
Building wheels for collected packages: cryptography
Running setup.py bdist_wheel for cryptography ... error
Complete output from command /usr/local/virtualenvs/profiles_api/profiles_api3/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-2sa4x5ab/cryptography/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" bdist_wheel -d /tmp/tmplvmgp_y8pip-wheel- --python-tag cp35:
Installed /tmp/pip-build-2sa4x5ab/cryptography/.eggs/cffi-1.11.5-py3.5-linux-x86_64.egg
Searching for pycparser
Reading https://pypi.python.org/simple/pycparser/
Best match: pycparser 2.18
Downloading https://files.pythonhosted.org/packages/8c/2d/aad7f16146f4197a11f8e91fb81df177adcc2073d36a17b1491fd09df6ed/pycparser-2.18.tar.gz#sha256=99a8ca03e29851d96616ad0404b4aad7d9ee16f25c9f9708a11faf2810f7b226
Processing pycparser-2.18.tar.gz
Writing /tmp/easy_install-_vc_2z13/pycparser-2.18/setup.cfg
Running pycparser-2.18/setup.py -q bdist_egg --dist-dir /tmp/easy_install-_vc_2z13/pycparser-2.18/egg-dist-tmp-omz1wtad
warning: no previously-included files matching 'yacctab.*' found under directory 'tests'
warning: no previously-included files matching 'lextab.*' found under directory 'tests'
warning: no previously-included files matching 'yacctab.*' found under directory 'examples'
warning: no previously-included files matching 'lextab.*' found under directory 'examples'
zip_safe flag not set; analyzing archive contents...
pycparser.ply.__pycache__.lex.cpython-35: module references __file__
pycparser.ply.__pycache__.lex.cpython-35: module MAY be using inspect.getsourcefile
pycparser.ply.__pycache__.ygen.cpython-35: module references __file__
pycparser.ply.__pycache__.yacc.cpython-35: module references __file__
pycparser.ply.__pycache__.yacc.cpython-35: module MAY be using inspect.getsourcefile
pycparser.ply.__pycache__.yacc.cpython-35: module MAY be using inspect.stack
creating /tmp/pip-build-2sa4x5ab/cryptography/.eggs/pycparser-2.18-py3.5.egg
Extracting pycparser-2.18-py3.5.egg to /tmp/pip-build-2sa4x5ab/cryptography/.eggs
Installed /tmp/pip-build-2sa4x5ab/cryptography/.eggs/pycparser-2.18-py3.5.egg
/usr/lib/python3.5/distutils/dist.py:261: UserWarning: Unknown distribution option: 'python_requires'
warnings.warn(msg)
usage: -c [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
or: -c --help [cmd1 cmd2 ...]
or: -c --help-commands
or: -c cmd --help
error: invalid command 'bdist_wheel'
----------------------------------------
Failed building wheel for cryptography
Running setup.py clean for cryptography
Failed to build cryptography
Installing collected packages: idna, asn1crypto, six, pycparser, cffi, cryptography
Running setup.py install for cryptography ... done
Successfully installed asn1crypto cffi cryptography idna pycparser six
I tried to create Python3 virtualenv and test some Python code in it:
python3 -m venv tbzuploader-py3env
cd tbzuploader-py3env
. ./bin/activate
pip install -e git+https://github.com/guettli/tbzuploader.git#egg=tbzuploader
Here is the output I get:
Obtaining tbzuploader from git+https://github.com/guettli/tbzuploader.git#egg=tbzuploader
Cloning https://github.com/guettli/tbzuploader.git to ./src/tbzuploader
Collecting requests (from tbzuploader)
Using cached requests-2.18.4-py2.py3-none-any.whl
Collecting future (from tbzuploader)
Using cached future-0.16.0.tar.gz
Collecting urllib3<1.23,>=1.21.1 (from requests->tbzuploader)
Using cached urllib3-1.22-py2.py3-none-any.whl
Collecting chardet<3.1.0,>=3.0.2 (from requests->tbzuploader)
Using cached chardet-3.0.4-py2.py3-none-any.whl
Collecting certifi>=2017.4.17 (from requests->tbzuploader)
Using cached certifi-2017.7.27.1-py2.py3-none-any.whl
Collecting idna<2.7,>=2.5 (from requests->tbzuploader)
Using cached idna-2.6-py2.py3-none-any.whl
Building wheels for collected packages: future
Running setup.py bdist_wheel for future ... error
Complete output from command /home/tguettler/projects/tbzuploader-py3env/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-4iiy_oby/future/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" bdist_wheel -d /tmp/tmpukjvdwtmpip-wheel- --python-tag cp35:
usage: -c [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
or: -c --help [cmd1 cmd2 ...]
or: -c --help-commands
or: -c cmd --help
error: invalid command 'bdist_wheel'
----------------------------------------
Failed building wheel for future
Running setup.py clean for future
Failed to build future
Installing collected packages: urllib3, chardet, certifi, idna, requests, future, tbzuploader
Running setup.py install for future ... done
Running setup.py develop for tbzuploader
Successfully installed certifi-2017.7.27.1 chardet-3.0.4 future-0.16.0 idna-2.6 requests-2.18.4 tbzuploader urllib3-1.22
You are using pip version 8.1.1, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
I use Python from Ubuntu 16.04:
===> python --version
Python 3.5.2
What am I doing wrong?
By default venv installed pip version 8. You should update it: pip install --upgrade pip
You need to update pip version by following command.
pip install --upgrade pip
When you install python3, pip3 gets installed. And if you don't have another python installation(like python2.7) then a link is created which points pip to pip3. pip generally points to the first installation.