Running Python in shell does not find installed packages
See original GitHub issue- I am on the latest Poetry version.
- I have searched the issues of this repo and believe that this is not a duplicate.
- OS version and name: macOS 10.14
- Poetry version: 0.12.17
- Link of a Gist with the contents of your pyproject.toml file: https://gist.github.com/slhck/5a5dc06d77046a894025d593447bfdc8
Issue
I want to use poetry shell
to run python3
with the packages installed via poetry
.
When I install the packages and run python3
from the shell, the packages are not found:
➜ poetry init
…
~/Desktop/test via 🐍 3.7.3
➜ poetry add fastapi uvicorn
Creating virtualenv test-py3.7 in /Users/werner/Library/Caches/pypoetry/virtualenvs
Using version ^0.42.0 for fastapi
Using version ^0.10.8 for uvicorn
Updating dependencies
Resolving dependencies... (4.9s)
Writing lock file
Package operations: 9 installs, 0 updates, 0 removals
- Installing click (7.0)
- Installing h11 (0.8.1)
- Installing httptools (0.0.13)
- Installing pydantic (0.32.2)
- Installing starlette (0.12.9)
- Installing uvloop (0.14.0)
- Installing websockets (8.1)
- Installing fastapi (0.42.0)
- Installing uvicorn (0.10.8)
~/Desktop/test via 🐍 3.7.3 took 19s
➜ poetry run python3 -c "import fastapi"
email-validator not installed, email fields will be treated as str.
To install, run: pip install email-validator
~/Desktop/test via 🐍 3.7.3 took 2s
➜ poetry shell
Spawning shell within /Users/werner/Library/Caches/pypoetry/virtualenvs/test-py3.7
~/Desktop/test via test-py3.7 via 🐍 3.7.3
➜ python3 -c "import fastapi"
Traceback (most recent call last):
File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'fastapi'
The module is not found when inside the shell, but it is when I use poetry run
.
Python 3 is 3.7.3 installed via pyenv
:
➜ pyenv versions
system
3.6.5
* 3.7.3 (set by PYENV_VERSION environment variable)
Unless I’ve missed something obvious, I think this is the way this tool is intended to be used. I also know pipenv shell
does the same, and from the documentation I don’t see any indication that the expected behavior would be different.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Why Can't Python Find My Modules?
A common error that new Pythonistas will come across is that the packages they think they've installed are not actually being recognized by ......
Read more >Python - package not found although it is installed
Use the Anaconda Python binary to run pip as a module; when you can run /path/to/python or pythoncommand to open the right Python...
Read more >Installing Packages - Python Packaging User Guide - Python.org
Run python get -pip.py . 2 This will install or upgrade pip. Additionally, it will install setuptools and wheel if they're not installed...
Read more >How to List Installed Python Packages
List Installed Packages with Anaconda Navigator · Start the Anaconda Navigator application. · Select Environments in the left column. · A dropdown ...
Read more >How does python find packages?
I just ran into a situation where I compiled and installed Python 2.7.9 from source on Ubuntu, but Python could not find 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
I just tried 1.0.0b5 and it works there.
Thanks a lot for coming back and reporting! 👍
So I will close this issue.