Skip to content

Install fails on macOS: "ModuleNotFoundError: No module named 'pip'" #22

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

Closed
sertal70 opened this issue May 20, 2019 · 4 comments
Closed
Labels
bug Something isn't working

Comments

@sertal70
Copy link

sertal70 commented May 20, 2019

I'm trying to install eb cli on a macOS 10.14.4 but without success.

When I run the installation script directly using the command python ebcli_installer.py this is the output I get:


***********************************
1. Locating virtualenv installation
***********************************

******************************************
2. Creating exclusive virtualenv for EBCLI
******************************************
Using base prefix '/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7'
New python executable in /Users/Sergio/.ebcli-virtual-env/bin/python3.7
Also creating executable in /Users/Sergio/.ebcli-virtual-env/bin/python
Installing setuptools, pip, wheel...
done.

************************
3. Activating virtualenv
************************

*******************
4. Installing EBCLI
*******************
Traceback (most recent call last):
  File "/Users/Sergio/.ebcli-virtual-env/bin/pip", line 6, in <module>
    from pip._internal import main
ModuleNotFoundError: No module named 'pip'

***********************
5. Creating EB wrappers
***********************

***************
6. Finishing up
***************
Success!

    Note: To complete installation, ensure `eb` is in PATH. You can ensure this by executing:

    1. Bash:

       echo 'export PATH="/Users/Sergio/.ebcli-virtual-env/executables:$PATH"' >> ~/.bash_profile && source ~/.bash_profile

    2. Zsh:

       echo 'export PATH="/Users/Sergio/.ebcli-virtual-env/executables:$PATH"' >> ~/.zshenv && source ~/.zshenv

As you can see in step 4 there is an error on pip module which is correctly installed and working in the system:

$ pip --version
pip 18.1 from /usr/local/lib/python3.7/site-packages/pip (python 3.7)

Anyway, after installation script has completed, I tried to execute the EB CLI but I've got the following error:

$ eb
Traceback (most recent call last):
  File "/Users/Sergio/.ebcli-virtual-env/executables/eb", line 45, in <module>
    exit(_exec_cmd(['/Users/Sergio/.ebcli-virtual-env/bin/eb'] + sys.argv[1:]))
  File "/Users/Sergio/.ebcli-virtual-env/executables/eb", line 25, in _exec_cmd
    p = subprocess.Popen(args)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 775, in __init__
    restore_signals, start_new_session)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 1522, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '/Users/Sergio/.ebcli-virtual-env/bin/eb': '/Users/Sergio/.ebcli-virtual-env/bin/eb'

which I suppose is a consequence of the error occurred during installation.

I don't think it is a matter with my env or virtualenv because if I create manually a virtualenv everything goes fine:

$ virtualenv test
Using base prefix '/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7'
New python executable in /Users/Sergio/Bidone/test-virtualend/test/bin/python3.7
Also creating executable in /Users/Sergio/Bidone/test-virtualend/test/bin/python
Installing setuptools, pip, wheel...
done.
$ source test/bin/activate
(test) $ python --version
Python 3.7.0
(test) $ pip --version
pip 19.1.1 from /Users/Sergio/Bidone/test-virtualend/test/lib/python3.7/site-packages/pip (python 3.7)

Any hint to sort out this issue would be very appreciated, thanks!

@rahulrajaram
Copy link
Contributor

@sertal70 , thanks for reaching out.

It is hard to say, but this is likely a problem with Python not finding the right set of packages to use. Notice that the pip associated with the Python that was used to create the virtualenv for the EB CLI in step 2:

/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/bin/<PIP EXECUTABLE>

is different from the one that is the default as shown by your execution of pip --version:

/usr/local/lib/python3.7/site-packages/pip

Basically, I think Python is not looking up the modules for /Users/Sergio/.ebcli-virtual-env/bin/pip in the right locations and hence is not able to find its own modules.

Either of the following approaches should fix your problem:

  1. Figure out whether there is a pip in /usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/bin/. If yes, temporarily add it to the head of the $PATH variable (export PATH="/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/bin:$PATH"). Remove ~/.ebcli-virtual-env and retry.

  2. Run ./bundled_installer. However, this will create a separate Python 3.7.2 installation in ~/.pyenv-repository/versions/3.7.2. This is, of course, redundant considering you already have (what look like) multiple Python's on your system, but it makes EB CLI installation predictable because ebcli_installer.py (through the bundled_installer) will know which Python it is that you are using.

Let me know if either of these solutions gets you around the problem.

(As for steps 5 and 6 in the output, they should have never been attempted, so that's a bug we should fix in the ebcli_installer.py script.)

@rahulrajaram rahulrajaram added the bug Something isn't working label May 20, 2019
@sertal70
Copy link
Author

Thanks @rahulrajaram for your answer. Actually I started using ebcli_installer.py because I already had python installed on my system, but thanks to your observation I found that python is installed both with MacPorts and Homebrew. It is something I will fix as soon as I'll have time but for now I ended using the bundled_installer to sort things out.

Another note: using the bundled_installer I've got the error:

zipimport.ZipImportError: can't decompress data; zlib not available
make: *** [install] Error 1
   Exiting due to failure

so I added the export variables suggested in the project's readme:

export LDFLAGS="-L/usr/local/opt/zlib/lib"
export CPPFLAGS="-I/usr/local/opt/zlib/include"

but it didn't solve the issue for a simple reason: zlib was not present in the specified location, so I had to install it with brew install zlib. Maybe it could be worth to add this info in the note.

@rahulrajaram
Copy link
Contributor

rahulrajaram commented May 22, 2019

@sertal70 , thanks for verifying, and reporting the subsequent problem along with your suggestion. Yes, we should add brew install zlib to the README.

rahulrajaram added a commit that referenced this issue May 23, 2019
Python 3.7.2 installation on OS X can fail if Zlib
modules are unavailable.

This issue was originally brought up in Issue #22 [1].

This commit recommends customers to run `brew install
zlib` prior to setting the linker and compiler flags
for zlib.

[1] - #22
rahulrajaram added a commit that referenced this issue May 23, 2019
This release fixes:

1. Issue involving spaces within virtualenv DEST_DIR path ( Issue #20 )
2. Non-determinism involved in choosing Python executable to create
   virtualenv with when multiple Pythons are available on the computer.
3. zlib-related recommendation for OS X in the README ( Issues #22 / #23 )
4. the continuation of the ebcli_installer.py script beyond its failure
   to install the EB CLI.
@rahulrajaram
Copy link
Contributor

Closing this issue because the problems identifies here have been addressed in release v0.1.2. git pull master to get the latest changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants