-
-
Notifications
You must be signed in to change notification settings - Fork 151
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Missed packages installed in virtual environment #130
Comments
Possibly related (Fedora 29 x86_64, Python 3.7.5) ... When I execute
(tryptools) $ python3 -m pipdeptree -l
ipython==7.18.1
- backcall [required: Any, installed: 0.2.0]
- decorator [required: Any, installed: 4.4.2]
- jedi [required: >=0.10, installed: 0.17.2]
- parso [required: >=0.7.0,<0.8.0, installed: 0.7.1]
- pexpect [required: >4.3, installed: 4.8.0]
- ptyprocess [required: >=0.5, installed: 0.6.0]
- pickleshare [required: Any, installed: 0.7.5]
- prompt-toolkit [required: >=2.0.0,<3.1.0,!=3.0.1,!=3.0.0, installed: 3.0.7]
- wcwidth [required: Any, installed: 0.2.5]
- pygments [required: Any, installed: 2.6.1]
- setuptools [required: >=18.5, installed: 50.1.0]
- traitlets [required: >=4.2, installed: 5.0.3]
- ipython-genutils [required: Any, installed: 0.2.0]
pipdeptree==1.0.0
- pip [required: >=6.0.0, installed: 20.2.2]
pipetools==0.3.5
- setuptools [required: >=0.6b1, installed: 50.1.0]
wheel==0.35.1 |
Sorry for the delay. I missed this issue! Will try to reproduce this and see if it can be fixed in the next release. Thanks! |
Seems no update in a while, so closing. If you can still replicate please comment and we can reopen. |
I am so sorry, but I just reproduced initial issue with Windows 11, Python 3.10.5, pipdeptree 2.2.1, pip 22.1.1, virtualenv 20.16.3 and netCDF4 1.6.0. |
Can you try with 2.3.0? |
Thank you! I do not see this error now. |
Hello, My system is Ubuntu 22.04.2 with pipdeptree 2.7.0 Best, |
I've got the same issue on Windows 11, Python 3.9.13, It does not list |
I have the same error. In a virtualenv with Python 3.10, and pipdeptree 2.13.0 installed in the virtualenv:
Thanks for the workaround with "python -m pipdeptree", but I still think this should be addressed. |
I can confirm that this is happening. I have pipdeptree dev dependencies installed, and a virtual environment created by doing the following: python -m venv --system-site-packages venv So the virtual environment shouldn't have anything in its site-packages directory. From executing the following: $ pipdeptree --local-only
covdefaults==2.3.0
└── coverage [required: >=6.0.2, installed: 7.4.4]
diff_cover==8.0.3
├── chardet [required: >=3.0.0, installed: 5.2.0]
├── Jinja2 [required: >=2.7.1, installed: 3.1.3]
│ └── MarkupSafe [required: >=2.0, installed: 2.1.5]
├── pluggy [required: >=0.13.1,<2, installed: 1.4.0]
└── Pygments [required: >=2.9.0,<3.0.0, installed: 2.17.2]
GitPython==3.1.41
└── gitdb [required: >=4.0.1,<5, installed: 4.0.11]
└── smmap [required: >=3.0.1,<6, installed: 5.0.1]
pipdeptree==2.16.3.dev27+g757c8ab.d20240329
├── packaging [required: >=23.1, installed: 24.0]
└── pip [required: >=23.1.2, installed: 24.0]
pre-commit==3.7.0
. . . ... we still get all of the global site packages. Running the workaround: (venv) $ python -m pipdeptree --local-only
pip==23.0.1
setuptools==58.1.0 ... gives the expected results. I did find the reason why this is happening, though. Since I'm running pipdeptree in editable mode, I can change the code to print out the (venv) $ pipdeptree --local-only
sys.prefix: /usr/local
covdefaults==2.3.0
└── coverage [required: >=6.0.2, installed: 7.4.4]
. . . Even though I'm running in a virtual environment, it uses the Unix default (venv) $ python -m pipdeptree --local-only
sys.prefix: /workspaces/pipdeptree/venv
pip==23.0.1
setuptools==58.1.0 The path points to the virtual env. Edit: My comment below discusses what I think is happening |
I do have another guess as to why this is happening. It could be that it depends on where If it's installed in the global site packages, where we then execute the console script in the virtual environment, it maybe the case that pipdeptree doesn't recognize that it's running in a virtual environment because we never give it the Python interpreter from the virtual environment. In the following example I installed
Looking at this, pipdeptree is using the system-provided Python interpreter when we expected it to use the one found in the virtual environment (since we executed it in the virtual environment). When it's installed in the virtual environment itself, I observed that running the console script will give the expected results:
We do have a |
Hi @bartoszgrabski, it sounds like your problem may have to do with what was discussed in #277. |
I can confirm the behavior with Let's install
System-wide
Now let's I install a Poetry project:
Here, I expect
For this to work, I need to pass the venv's Python:
|
BTW, a more robust way of running
|
Thanks for your input @kdeldycke! There was a similar issue, #322, that reported a problem when using pipx. The pipdeptree console script would be available globally, but from reading this section in the pipx README, pipdeptree would be sandboxed into it's own virtual environment without system site packages enabled. Here's an example where I installed pipdeptree using pipx: $ pipx --version
1.5.0
$ which pipdeptree
/usr/local/py-utils/bin/pipdeptree
$ cat /usr/local/py-utils/venvs/pipdeptree/p
pipx_metadata.json pyvenv.cfg
$ cat /usr/local/py-utils/venvs/pipdeptree/pyvenv.cfg
home = /usr/local/py-utils/venvs/pipx/bin
include-system-site-packages = false
version = 3.8.19
$ /usr/local/py-utils/bin/pipdeptree
Warning!!! Duplicate package metadata found:
"/home/vscode/.local/lib/python3.8/site-packages"
packaging 24.0 (using 24.0, "/usr/local/py-utils/venvs/pipdeptree/lib/python3.8/site-packages")
pip 24.0 (using 24.0, "/usr/local/py-utils/shared/lib/python3.8/site-packages")
"/usr/local/lib/python3.8/site-packages"
pip 23.0.1 (using 24.0, "/usr/local/py-utils/shared/lib/python3.8/site-packages")
setuptools 69.0.3 (using 56.0.0, "/usr/local/py-utils/shared/lib/python3.8/site-packages")
------------------------------------------------------------------------
covdefaults==2.3.0
└── coverage [required: >=6.0.2, installed: 7.4.4]
diff_cover==9.0.0
├── chardet [required: >=3.0.0, installed: 5.2.0]
├── Jinja2 [required: >=2.7.1, installed: 3.1.3]
│ └── MarkupSafe [required: >=2.0, installed: 2.1.5]
├── pluggy [required: >=0.13.1,<2, installed: 1.4.0]
└── Pygments [required: >=2.9.0,<3.0.0, installed: 2.17.2]
. . . |
Yes, you should use If users are still having problems after 2.18.0, please let us know and I'll see if I can figure it out. In short, this is how you should run pipdeptree when working with a virtual environment:
|
With pipdeptree 2.21.0 release (and thanks to #366), we can now rely on So I guess this issue can now be requalified as whether or not we should make |
I vote for this default behaviour because I'm here as a new pipdeptree user that was fighting to see a venv dependencies. |
How to reproduce the issue (Windows 10 64 bit, Python 3.8.5 64 bit):
Install pipdeptree in site-packages (using admin rights).
Create empty directory, switch there.
Create virtual environment using venv or virtualenv:
virtualenv --clear --system-site-packages .venv
python -m venv --clear --system-site-packages .venv
Activate it:
.venv/scripts/activate.bat
Install any package/module in virtual environment (I initially discovered this issue with netCDF4):
(.venv)>pip install -U netCDF4
Run pipdeptree using console entry point:
(.venv)>pipdeptree
Module netCDF4 will not be listed. Initially I thought that it is an error with this specific module, but later discovered, that it occurs with pandas etc.
(Workaround) Run pipdeptree as a module
(.venv)>python -m pipdeptree
Module netCDF4 will be listed...
P.S. By the way, pip started as the console entry point (pip) and as a module (python -m pip) in both cases behaves properly.
The text was updated successfully, but these errors were encountered: