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

no module named pip.req #8

Open
mcgibbon opened this issue Aug 23, 2018 · 5 comments
Open

no module named pip.req #8

mcgibbon opened this issue Aug 23, 2018 · 5 comments

Comments

@mcgibbon
Copy link
Contributor

setup.py seems to currently suffer from this problem, will need to fix it at some point.

@98440622
Copy link

Got the same problem using python 3.7.0 (Anaconda).

@ozel
Copy link

ozel commented Jul 2, 2020

how can this be circumvented? I have the same installation issue with Python 3.8 and anaconda.
The try/except block suggested as fix on stackoverflow above seems already implemented in setup.py (https://stackoverflow.com/a/49867265).

@mcgibbon
Copy link
Contributor Author

mcgibbon commented Jul 2, 2020

I would be satisfied to merge a PR moving the requirements into the setup.py file, as in this repo.

@ozel
Copy link

ozel commented Jul 4, 2020

thanks for the pointer, this seems to do the trick on my system but it is also the first time that I am fiddling with a setup.py file.
I also needed to install manually libudunits2-0 on Ubuntu to make cfunits happy.

diff --git a/setup.py b/setup.py
index 1e085af..f14817f 100644
--- a/setup.py
+++ b/setup.py
@@ -1,15 +1,18 @@
 from setuptools import setup
-try: # for pip >= 10
-    from pip._internal.req import parse_requirements
-except ImportError: # for pip <= 9.0.3
-    from pip.req import parse_requirements
+#try: # for pip >= 10
+#    from pip._internal.req import parse_requirements
+#except ImportError: # for pip <= 9.0.3
+#   from pip.req import parse_requirements
 
 # parse_requirements() returns generator of pip.req.InstallRequirement objects
-install_reqs = parse_requirements('requirements.txt', session=False)
+#install_reqs = parse_requirements('requirements.txt', session=False)
+
+with open("requirements.txt") as reqs_file:
+    reqs = [line.strip() for line in reqs_file]
 
 # reqs is a list of requirement
 # e.g. ['django==1.5.1', 'mezzanine==1.4.6']
-reqs = [str(ir.req) for ir in install_reqs]
+#reqs = [str(ir.req) for ir in install_reqs]

@mcgibbon
Copy link
Contributor Author

mcgibbon commented Jul 6, 2020

Yes, adding cfunits support broke the package CI testing since libudunits has to be installed manually. I was thinking of removing it (or making it optional) back when I (mostly) stopped working on this code.

mcgibbon pushed a commit that referenced this issue Dec 16, 2020
Every time I tried to install the develop version of the atmos package either via `pip install` or `pipenv install`, I was facing an error most likely related to the issue that was addresed in issue #8. The `req` module has been moved to the `pip._internal.req` submodule, so the try except in `setup.py` seems to solve the issue of importing the `parse_requirements` function.

However, some extra changes might have happened on the  `pip` side, because apparently, now, the `ParsedRequirement` class has had its `req` attribute renamed to `requirement`, which caused an `AttributeError`. 

I solved this in my machine via another try and except clause that should handle older and newer pip versions.
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

3 participants