-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Unable to import package with a name different from the project name #5744
Comments
Hey, I think what you want to use is:
|
Hi @GenosW Even with this configuration, it still not works, but now with a different error. |
What are you trying to do? Which command are you invoking? --> There is some context missing to effectively help you. Did Note: I'm not a poetry developer, just an avid user. |
for now I'm just trying to import the installed package. import crossref Yes poetry install works fine, the issue is: I can not import the package. (.venv) fabiobatalha:~/Work/crossrefapi$ poetry install
Installing dependencies from lock file
No dependencies to install or update
Installing the current project: crossrefapi (1.6.0)
(.venv) fabiobatalha:~/Work/crossrefapi$ python
Python 3.8.10 (default, Mar 15 2022, 12:22:08)
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import crossref
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/fabiobatalha/Work/crossrefapi/src/crossref/__init__.py", line 3, in <module>
VERSION = pkg_resources.get_distribution("crossref").version
File "/home/fabiobatalha/Work/crossrefapi/.venv/lib/python3.8/site-packages/pkg_resources/__init__.py", line 478, in get_distribution
dist = get_provider(dist)
File "/home/fabiobatalha/Work/crossrefapi/.venv/lib/python3.8/site-packages/pkg_resources/__init__.py", line 354, in get_provider
return working_set.find(moduleOrReq) or require(str(moduleOrReq))[0]
File "/home/fabiobatalha/Work/crossrefapi/.venv/lib/python3.8/site-packages/pkg_resources/__init__.py", line 909, in require
needed = self.resolve(parse_requirements(requirements))
File "/home/fabiobatalha/Work/crossrefapi/.venv/lib/python3.8/site-packages/pkg_resources/__init__.py", line 795, in resolve
raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'crossref' distribution was not found and is required by the application
>>>
|
@fabiobatalha recreate your virtualenv. |
Not even with a new virtualenv. (.venv) fabiobatalha:~/Work/crossrefapi$ poetry install
Installing dependencies from lock file
Package operations: 41 installs, 0 updates, 0 removals
• Installing six (1.16.0)
• Installing asttokens (2.0.5)
• Installing executing (0.8.3)
• Installing parso (0.8.3)
• Installing ptyprocess (0.7.0)
• Installing pure-eval (0.2.2)
• Installing pyparsing (3.0.9)
• Installing traitlets (5.2.2.post1)
• Installing wcwidth (0.2.5)
• Installing attrs (21.4.0)
• Installing backcall (0.2.0)
• Installing certifi (2022.5.18.1)
• Installing charset-normalizer (2.0.12)
• Installing click (8.1.3)
• Installing decorator (5.1.1)
• Installing idna (3.3)
• Installing iniconfig (1.1.1)
• Installing jedi (0.18.1)
• Installing matplotlib-inline (0.1.3)
• Installing mccabe (0.6.1)
• Installing mypy-extensions (0.4.3)
• Installing packaging (21.3)
• Installing pathspec (0.9.0)
• Installing pexpect (4.8.0)
• Installing pickleshare (0.7.5)
• Installing platformdirs (2.5.2)
• Installing pluggy (1.0.0)
• Installing prompt-toolkit (3.0.29)
• Installing py (1.11.0)
• Installing pycodestyle (2.8.0)
• Installing pyflakes (2.4.0)
• Installing pygments (2.12.0)
• Installing stack-data (0.2.0)
• Installing tomli (2.0.1)
• Installing typing-extensions (4.2.0)
• Installing urllib3 (1.26.9)
• Installing black (22.3.0)
• Installing flake8 (4.0.1)
• Installing ipython (8.4.0)
• Installing pytest (7.1.2)
• Installing requests (2.27.1)
Installing the current project: crossrefapi (1.6.0)
(.venv) fabiobatalha:~/Work/crossrefapi$ python
Python 3.8.10 (default, Mar 15 2022, 12:22:08)
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import crossref
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/fabiobatalha/Work/crossrefapi/src/crossref/__init__.py", line 3, in <module>
VERSION = pkg_resources.get_distribution("crossref").version
File "/home/fabiobatalha/Work/crossrefapi/.venv/lib/python3.8/site-packages/pkg_resources/__init__.py", line 478, in get_distribution
dist = get_provider(dist)
File "/home/fabiobatalha/Work/crossrefapi/.venv/lib/python3.8/site-packages/pkg_resources/__init__.py", line 354, in get_provider
return working_set.find(moduleOrReq) or require(str(moduleOrReq))[0]
File "/home/fabiobatalha/Work/crossrefapi/.venv/lib/python3.8/site-packages/pkg_resources/__init__.py", line 909, in require
needed = self.resolve(parse_requirements(requirements))
File "/home/fabiobatalha/Work/crossrefapi/.venv/lib/python3.8/site-packages/pkg_resources/__init__.py", line 795, in resolve
raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'crossref' distribution was not found and is required by the application
>>>
|
You should try using That said I suspect the issue was fixed in #5703. You can try using the version of poetry from master. You can workaround this issue by moving the version discovery into it's own module rather than |
Your distribution is still |
oh yeah; @finswimmer is right - missed that. Just change this. - VERSION = pkg_resources.get_distribution("crossref").version
+ VERSION = pkg_resources.get_distribution("crossrefapi").version |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
I'm moving a library to use poetry. This library has a name that is different from the main package. It works well with setuptools and the function : packages=find_packages().
With poetry I have the following configuration:
But the package crossref is still not available for import.
I don't know what could be wrong.
The text was updated successfully, but these errors were encountered: