Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Welcome to Software Development on Codidact!

Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.

Post History

66%
+2 −0
Q&A Why can't I use a library I just installed with Pip?

I tried installing package-installation-test[1] using Pip, and it appeared to be successful. But I can't use it as advertised, either by itself or by importing it from my code: Failed attempts ...

1 answer  ·  posted 5mo ago by Karl Knechtel‭  ·  edited 5mo ago by Karl Knechtel‭

#2: Post edited by user avatar Karl Knechtel‭ · 2024-06-16T13:59:35Z (5 months ago)
hide examples because they aren't strictly necessary to describe the problem; add some colour
  • I tried installing [`package-installation-test`](https://pypi.org/project/package-installation-test/)[^1] using Pip, and it appeared to be successful. But I can't use it as advertised, either by itself or by importing it from my code:
  • ```bash
  • $ pip install package-installation-test
  • Collecting package-installation-test
  • Using cached package_installation_test-1.0.0-py3-none-any.whl (3.1 kB)
  • Installing collected packages: package-installation-test
  • Successfully installed package-installation-test-1.0.0
  • $ demo-example-package
  • demo-example-package: command not found
  • $ python -m example_package
  • /path/to/python: No module named example_package
  • $ python -q
  • >>> import example_package
  • Traceback (most recent call last):
  • File "<stdin>", line 1, in <module>
  • ModuleNotFoundError: No module named 'example_package'
  • >>>
  • ```
  • Also, `demo-example-package` doesn't tab-complete in my shell.
  • According to the documentation, I should get results like this instead:
  • ```bash
  • $ demo-example-package
  • Version 1.0.0 of example_package successfully installed.
  • The source code is in /path/to/example_package.
  • $ python -m example_package
  • Version 1.0.0 of example_package successfully installed.
  • The source code is in /path/to/example_package.
  • $ python -q
  • >>> import example_package # no error
  • >>> example_package.home()
  • PosixPath('/path/to/example_package')
  • ```
  • Attempting to reinstall doesn't work either:
  • ```
  • $ pip install package-installation-test
  • Requirement already satisfied: package-installation-test in /path/to/site-packages (1.0.0)
  • ```
  • What gives?
  • [^1]: Full disclosure: I am the author of this package. I created it specifically to demonstrate the problem for the purpose of a canonical Q&A. Whatever package you're actually trying to install and use, the fundamentally problem is still the same.
  • I tried installing [`package-installation-test`](https://pypi.org/project/package-installation-test/)[^1] using Pip, and it appeared to be successful. But I can't use it as advertised, either by itself or by importing it from my code:
  • <details><summary>Failed attempts</summary>
  • <section class="notice is-danger">
  • ```bash
  • $ pip install package-installation-test
  • Collecting package-installation-test
  • Using cached package_installation_test-1.0.0-py3-none-any.whl (3.1 kB)
  • Installing collected packages: package-installation-test
  • Successfully installed package-installation-test-1.0.0
  • $ demo-example-package
  • demo-example-package: command not found
  • $ python -m example_package
  • /path/to/python: No module named example_package
  • $ python -q
  • >>> import example_package
  • Traceback (most recent call last):
  • File "<stdin>", line 1, in <module>
  • ModuleNotFoundError: No module named 'example_package'
  • >>>
  • ```
  • </section></details>
  • Also, `demo-example-package` doesn't tab-complete in my shell.
  • According to the documentation, I should get results like this instead:
  • <details><summary>Expected results</summary>
  • <section class="notice is-success">
  • ```bash
  • $ demo-example-package
  • Version 1.0.0 of example_package successfully installed.
  • The source code is in /path/to/example_package.
  • $ python -m example_package
  • Version 1.0.0 of example_package successfully installed.
  • The source code is in /path/to/example_package.
  • $ python -q
  • >>> import example_package # no error
  • >>> example_package.home()
  • PosixPath('/path/to/example_package')
  • ```
  • </section></details>
  • Attempting to reinstall doesn't work either:
  • <section class="notice is-warning">
  • ```
  • $ pip install package-installation-test
  • Requirement already satisfied: package-installation-test in /path/to/site-packages (1.0.0)
  • ```
  • </section>
  • What gives?
  • [^1]: Full disclosure: I am the author of this package. I created it specifically to demonstrate the problem for the purpose of a canonical Q&A. Whatever package you're actually trying to install and use, the fundamentally problem is still the same.
#1: Initial revision by user avatar Karl Knechtel‭ · 2024-06-16T13:19:01Z (5 months ago)
Why can't I use a library I just installed with Pip?
I tried installing [`package-installation-test`](https://pypi.org/project/package-installation-test/)[^1] using Pip, and it appeared to be successful. But I can't use it as advertised, either by itself or by importing it from my code:
```bash
$ pip install package-installation-test
Collecting package-installation-test
  Using cached package_installation_test-1.0.0-py3-none-any.whl (3.1 kB)
Installing collected packages: package-installation-test
Successfully installed package-installation-test-1.0.0
$ demo-example-package
demo-example-package: command not found
$ python -m example_package
/path/to/python: No module named example_package
$ python -q
>>> import example_package
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'example_package'
>>> 
```
Also, `demo-example-package` doesn't tab-complete in my shell.

According to the documentation, I should get results like this instead:
```bash
$ demo-example-package 
Version 1.0.0 of example_package successfully installed.
The source code is in /path/to/example_package.
$ python -m example_package
Version 1.0.0 of example_package successfully installed.
The source code is in /path/to/example_package.
$ python -q
>>> import example_package # no error
>>> example_package.home()
PosixPath('/path/to/example_package')
```
Attempting to reinstall doesn't work either:
```
$ pip install package-installation-test
Requirement already satisfied: package-installation-test in /path/to/site-packages (1.0.0)
```
What gives?

[^1]: Full disclosure: I am the author of this package. I created it specifically to demonstrate the problem for the purpose of a canonical Q&A. Whatever package you're actually trying to install and use, the fundamentally problem is still the same.