Skip to content
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

python3 does not see a pip-installed package, but python does, despite both being python3.9 #373

Open
nachogoro opened this issue Dec 6, 2020 · 1 comment

Comments

@nachogoro
Copy link

Minimal reproduction steps

  1. Create a new project (e.g. mkdir -p ~/projects/test-project)
  2. Create its own virtual environment:
$ cd ~/projects/test-project/
$ pyenv install 3.9.0
$ pyenv virtualenv 3.9.0 testproject-venv
$ pyenv local testproject-venv
  1. Create a simple script which requires a missing package:
    $ printf "from money import Money\nprint(\"Success\")" > main.py
  2. Attempting to execute the script fails as expected:
$ python3 main.py 
Traceback (most recent call last):
  File "/home/ng/projects/test-project/main.py", line 1, in <module>
    from money import Money
ModuleNotFoundError: No module named 'money'
  1. Install the missing package:
    $ pip install money
  2. Re-attempt to launch the script and see it fail when using python3 but succeeding with python:
$ python main.py 
Success
$ python3 main.py 
Traceback (most recent call last):
  File "/home/ng/projects/test-project/main.py", line 1, in <module>
    from money import Money
ModuleNotFoundError: No module named 'money'

Both python and python3 are aliases to the same binary:

$ ls -lh $(pyenv which python)
lrwxrwxrwx 1 ng ng 9 Dec  6 15:04 /home/ng/.pyenv/versions/testproject-venv/bin/python -> python3.9
$ ls -lh $(pyenv which python3)
lrwxrwxrwx 1 ng ng 9 Dec  6 15:04 /home/ng/.pyenv/versions/testproject-venv/bin/python3 -> python3.9

What am I missing? Thanks in advance :)

@grizmin
Copy link

grizmin commented Apr 2, 2023

What you miss is that pyenv which python doesn't guarantee you, that you execute python3 from this path.
What is the output of command -V python3 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants