Amazon AMI Linux returns incorrect value for sysconfig.get_path('purelib') in venvs
See original GitHub issueDescribe the bug
Pipx fails to install any package complaining that pipx_shared.pth
file is not found. I looked throughout issues and couldn’t find anything similar.
How to reproduce
- Create a Cloud9 environment (web IDE)
- Install pipx:
python3 -m pip install pipx --user
- Install any package
OS, Python, Pipx version:
Admin:~/environment $ python3 --version
Python 3.6.8
Admin:~/environment $ pipx --version
0.14.0.0
Admin:~/environment $ cat /etc/os-release
NAME="Amazon Linux AMI"
VERSION="2018.03"
ID="amzn"
ID_LIKE="rhel fedora"
VERSION_ID="2018.03"
PRETTY_NAME="Amazon Linux AMI 2018.03"
ANSI_COLOR="0;33"
CPE_NAME="cpe:/o:amazon:linux:2018.03:ga"
HOME_URL="http://aws.amazon.com/amazon-linux-ami/"
Trace with pipx --verbose
:
pipx install cfn-lint --verbose
pipx > (run_pipx_command:134): Virtual Environment location is /home/ec2-user/.local/pipx/venvs/cfn-lint
pipx > (run:97): running /usr/bin/python3 -m venv --without-pip /home/ec2-user/.local/pipx/venvs/cfn-lint
pipx > (rmdir:16): removing directory /home/ec2-user/.local/pipx/venvs/cfn-lint
Traceback (most recent call last):
File "/home/ec2-user/.local/bin/pipx", line 10, in <module>
sys.exit(cli())
File "/home/ec2-user/.local/lib/python3.6/site-packages/pipx/main.py", line 547, in cli
exit(run_pipx_command(parsed_pipx_args))
File "/home/ec2-user/.local/lib/python3.6/site-packages/pipx/main.py", line 166, in run_pipx_command
include_dependencies=args.include_deps,
File "/home/ec2-user/.local/lib/python3.6/site-packages/pipx/commands.py", line 315, in install
venv.create_venv(venv_args, pip_args)
File "/home/ec2-user/.local/lib/python3.6/site-packages/pipx/Venv.py", line 128, in create_venv
pipx_pth.write_text(str(shared_libs.site_packages) + "\n", encoding="utf-8")
File "/usr/lib64/python3.6/pathlib.py", line 1215, in write_text
with self.open(mode='w', encoding=encoding, errors=errors) as f:
File "/usr/lib64/python3.6/pathlib.py", line 1183, in open
opener=self._opener)
File "/usr/lib64/python3.6/pathlib.py", line 1037, in _opener
return self._accessor.open(self, flags, mode)
File "/usr/lib64/python3.6/pathlib.py", line 387, in wrapped
return strfunc(str(pathobj), *args)
FileNotFoundError: [Errno 2] No such file or directory: '/home/ec2-user/.local/pipx/venvs/cfn-lint/local/lib/python3.6/site-packages/pipx_shared.pth'
Expected behavior
Install a package
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Troubleshoot EC2 Linux instance status check failure due to ...
The file system entries in /etc/fstab are incorrect or the file system is corrupted. There are incorrect network configurations on the instance.
Read more >Change the hostname of your Amazon Linux instance
For Amazon Linux AMI: On your instance, open the /etc/sysconfig/network ... Change the \h (the symbol for hostname ) in that line to...
Read more >Query for the latest Amazon Linux AMI IDs using AWS ...
Upon querying, an AMI namespace returns only its regional ImageID value. The namespace is made up of two parts: Parameter Store Prefix (tree):...
Read more >Troubleshoot instances with failed status checks
For Linux-based instances that have failed an instance status check, such as the instance reachability ... ERROR Invalid kernel (EC2 incompatible kernel).
Read more >Troubleshoot Amazon EC2 Auto Scaling: AMI issues
Value (<ami ID>) for parameter virtualName is invalid. · Cause: Incorrect value. The virtualName parameter refers to the virtual name associated with the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is an issue with how Python is configured in the the Amazon Linux AMI environment. The configuration appears to break the
venv
module in general, not just withinpipx
. For some reason I have yet to determine, “/local” in injected after the venv name.The environment also has an undocumented variable exported
PYTHON_INSTALL_LAYOUT=amzn
which appears to cause other issues. Unsetting this variable and creating a new venv had no impact on the returned path.Python 3 “purelib” outside of a venv:
Python 3 “purelib” inside of a venv:
Python3 “purelib” inside of an activated venv, things work as expected:
If you activate the pipx venv via
source ~/.local/pipx/shared/bin/activate
before you install packages, things work as expected.@cs01 Do you want to keep this open to further workaround the issue? It appears very specific to Amazon’s AMI Linux configuration.
@sahensley thanks for the investigative work. I think the best path forward would be to file an issue somewhere with Amazon about this and to close this as a “won’t fix” since activating a venv before installing is not something pipx can do.