stefmolin / Hands-On-Data-Analysis-with-Pandas-2nd-edition

Materials for following along with Hands-On Data Analysis with Pandas – Second Edition
https://www.amazon.com/Hands-Data-Analysis-Pandas-visualization/dp/1800563450
MIT License
577 stars 1.38k forks source link

Troubles in installation packages with pip3 install -r requirements.txt #24

Closed lxlofpku closed 1 year ago

lxlofpku commented 1 year ago

Required attestation


Background information

1. Which OS are you using?

Mac airbook M2

2. Which Python version are you using?

Python3 from the current anaconda3

3. Are you using conda or venv?

conda


Commands run and their outputs

Please provide all of the commands you ran as well as the traceback:

``` $ conda create --name book_env python=3.8 $ conda activate book_env $ pip3 install -r requirements.txt Collecting git+https://github.com/stefmolin/login-attempt-simulator.git@2nd_edition (from -r requirements.txt (line 15)) Cloning https://github.com/stefmolin/login-attempt-simulator.git (to revision 2nd_edition) to /private/var/folders/s9/zk8r4hnd1p9dh9tf9s0xytfw0000gn/T/pip-req-build-pb8bm614 Running command git clone --filter=blob:none --quiet https://github.com/stefmolin/login-attempt-simulator.git /private/var/folders/s9/zk8r4hnd1p9dh9tf9s0xytfw0000gn/T/pip-req-build-pb8bm614 fatal: unable to access 'https://github.com/stefmolin/login-attempt-simulator.git/': HTTP/2 stream 1 was not closed cleanly before end of the underlying stream error: subprocess-exited-with-error × git clone --filter=blob:none --quiet https://github.com/stefmolin/login-attempt-simulator.git /private/var/folders/s9/zk8r4hnd1p9dh9tf9s0xytfw0000gn/T/pip-req-build-pb8bm614 did not run successfully. │ exit code: 128 ╰─> See above for output. note: This error originates from a subprocess, and is likely not a problem with pip. error: subprocess-exited-with-error × git clone --filter=blob:none --quiet https://github.com/stefmolin/login-attempt-simulator.git /private/var/folders/s9/zk8r4hnd1p9dh9tf9s0xytfw0000gn/T/pip-req-build-pb8bm614 did not run successfully. │ exit code: 128 ╰─> See above for output. note: This error originates from a subprocess, and is likely not a problem with pip. ```

Notes

By the way, I did not clone the files since I am not formiliar with the clone tool. Instead, I downloaded the whole .zip file then unzip the contents into my local directory.

Any help will be appreciated.

Best regards, Li-Xin Li

stefmolin commented 1 year ago

@lxlofpku - First, for M1 Macs and I imagine M2 as well, you will need to use Python 3.9 instead of 3.8, so you need to recreate the environment.

The issue you pasted above might be related to the git config on your machine and the use of HTTP/2 instead of HTTP/1.1 — if you still have issues after recreating your environment, try running the following:

git config --global http.version HTTP/1.1
pip3 install -r requirements.txt
lxlofpku commented 1 year ago

@stefmolin

Hi Stefanie:

Thank you very much for your quick reply. I tried accordinhg to what you said, i.e.:

conda env remove --name book_env

conda create --name book_env python=3.9

git config --global http.version HTTP/1.1

conda activate book_env

pip3 install -r requirements.txt

But I am still getting the problem:

......... Cloning https://github.com/stefmolin/stock-analysis.git (to revision 2nd_edition) to /private/var/folders/s9/zk8r4hnd1p9dh9tf9s0xytfw0000gn/T/pip-req-build-x4bvnr8k Running command git clone --filter=blob:none --quiet https://github.com/stefmolin/stock-analysis.git /private/var/folders/s9/zk8r4hnd1p9dh9tf9s0xytfw0000gn/T/pip-req-build-x4bvnr8k fatal: unable to access 'https://github.com/stefmolin/stock-analysis.git/': Empty reply from server error: subprocess-exited-with-error

× git clone --filter=blob:none --quiet https://github.com/stefmolin/stock-analysis.git /private/var/folders/s9/zk8r4hnd1p9dh9tf9s0xytfw0000gn/T/pip-req-build-x4bvnr8k did not run successfully. │ exit code: 128 ╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip. error: subprocess-exited-with-error

× git clone --filter=blob:none --quiet https://github.com/stefmolin/stock-analysis.git /private/var/folders/s9/zk8r4hnd1p9dh9tf9s0xytfw0000gn/T/pip-req-build-x4bvnr8k did not run successfully. │ exit code: 128 ╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

Best wishes, Li-Xin

stefmolin commented 1 year ago

Try deleting the environment and following the steps here.

lxlofpku commented 1 year ago

@stefmolin

I tried to install mamba by "conda install mamba -n base -c conda-forge" but I get the following:

""" Collecting package metadata (current_repodata.json): done Solving environment: failed with initial frozen solve. Retrying with flexible solve. Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source. Collecting package metadata (repodata.json): done Solving environment: failed with initial frozen solve. Retrying with flexible solve. Solving environment: - Found conflicts! Looking for incompatible packages. This can take several minutes. Press CTRL-C to abort. Examining conflict for backcall nbformat appscript snowballstemmer jupyterlab_widgets anaconda executing \ c """

then it keep "examing" for several hours without finishement. So, I did not success in taling the mamba...I even tried to reinstall the anaconda, but it still like the above when running "conda install mamba -n base -c conda-forge".

I tried to install a new version of git then repeat the process with conda, then when I run "pip3 install -r requirements.txt" I get

""" (book_env) lxl@LideMacBook-Air Hands-On-Data-Analysis-with-Pandas-2nd-edition % pip3 install -r requirements.txt Collecting git+https://github.com/stefmolin/login-attempt-simulator.git@2nd_edition (from -r requirements.txt (line 15)) Cloning https://github.com/stefmolin/login-attempt-simulator.git (to revision 2nd_edition) to /private/var/folders/s9/zk8r4hnd1p9dh9tf9s0xytfw0000gn/T/pip-req-build-gp3d_qhd Running command git clone --filter=blob:none --quiet https://github.com/stefmolin/login-attempt-simulator.git /private/var/folders/s9/zk8r4hnd1p9dh9tf9s0xytfw0000gn/T/pip-req-build-gp3d_qhd Running command git checkout -q 76e065a122343ebdd51c1cae98fbb8285411c0ff Resolved https://github.com/stefmolin/login-attempt-simulator.git to commit 76e065a122343ebdd51c1cae98fbb8285411c0ff Preparing metadata (setup.py) ... done Collecting git+https://github.com/stefmolin/ml-utils.git@2nd_edition (from -r requirements.txt (line 16)) Cloning https://github.com/stefmolin/ml-utils.git (to revision 2nd_edition) to /private/var/folders/s9/zk8r4hnd1p9dh9tf9s0xytfw0000gn/T/pip-req-build-9zs3shx6 Running command git clone --filter=blob:none --quiet https://github.com/stefmolin/ml-utils.git /private/var/folders/s9/zk8r4hnd1p9dh9tf9s0xytfw0000gn/T/pip-req-build-9zs3shx6 fatal: cannot access 'https://github.com/stefmolin/ml-utils.git/':OpenSSL SSL_read: error:0A000126:SSL routines::unexpected eof while reading, errno 0 error: subprocess-exited-with-error

× git clone --filter=blob:none --quiet https://github.com/stefmolin/ml-utils.git /private/var/folders/s9/zk8r4hnd1p9dh9tf9s0xytfw0000gn/T/pip-req-build-9zs3shx6 did not run successfully. │ exit code: 128 ╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip. error: subprocess-exited-with-error

× git clone --filter=blob:none --quiet https://github.com/stefmolin/ml-utils.git /private/var/folders/s9/zk8r4hnd1p9dh9tf9s0xytfw0000gn/T/pip-req-build-9zs3shx6 did not run successfully. │ exit code: 128 ╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip. """

So far, no success.

Best regards, Li-Xin

stefmolin commented 1 year ago

I often find that conda hangs like that, which was why I suggested mamba. It sounds like you may have some configuration issues on your machine. All issues have been related to making web requests (protocol, SSL) — you are indeed connected to the Internet when you try to install, correct? You might need to update some system libraries like openssl to make those web requests, if you are. Your best bet on the configuration issues would be to Google.

Here are a few things you can try outside of that.

Try deleting your environment and creating it this way:

conda env create --file environment.yml

If that doesn't work, the only other idea I have to install locally would be the following:

  1. Recreate the conda environment with Python 3.9
  2. Remove the last 4 lines of the requirements.txt file and then run the pip install command from before.
  3. Download the zip files for each of those repos, unzip, change into that directory, and then run pip3 install . (this exact command) from there:
  4. Change back to the book's directory and run pip3 install ./visual-aids

Note that doing this means that some of the code in the repos you download in step 3 may be different from what is presented in the book. The code in the book is under the tag 2nd_edition in each repo.

On another note, Binder is also a great option if you experience local installation issues, since it is already configured.

lxlofpku commented 1 year ago

@stefmolin

Hi Stefanie:

I followed the "four steps" approach but encountered a problem again in the step 2. After removing the last four lines from requirments.txt, I ran "pip3 install -r requirements.txt" but got:

.............. building 'npymath' library compiling C sources C compiler: clang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -fwrapv -O2 -Wall -fPIC -O2 -isystem /Users/lxl/opt/anaconda3/envs/book_env/include -arch x86_64 -I/Users/lxl/opt/anaconda3/envs/book_env/include -fPIC -O2 -isystem /Users/lxl/opt/anaconda3/envs/book_env/include -arch x86_64

        compile options: '-Ibuild/src.macosx-10.9-x86_64-3.9/numpy/core/src/npymath -Inumpy/core/include -Ibuild/src.macosx-10.9-x86_64-3.9/numpy/core/include/numpy -Inumpy/core/src/common -Inumpy/core/src -Inumpy/core -Inumpy/core/src/npymath -Inumpy/core/src/multiarray -Inumpy/core/src/umath -Inumpy/core/src/npysort -I/Users/lxl/opt/anaconda3/envs/book_env/include/python3.9 -Ibuild/src.macosx-10.9-x86_64-3.9/numpy/core/src/common -Ibuild/src.macosx-10.9-x86_64-3.9/numpy/core/src/npymath -Ibuild/src.macosx-10.9-x86_64-3.9/numpy/core/src/common -Ibuild/src.macosx-10.9-x86_64-3.9/numpy/core/src/npymath -c'
        llvm-ar: adding 4 object files to build/temp.macosx-10.9-x86_64-cpython-39/libnpymath.a
        error: Command "/var/folders/sy/f16zz6x50xz3113nwtb9bvq00000gp/T/abs_5a6dxej6x9/croot/python-split_1665695291976/_build_env/bin/llvm-ar rcs build/temp.macosx-10.9-x86_64-cpython-39/libnpymath.a build/temp.macosx-10.9-x86_64-cpython-39/numpy/core/src/npymath/npy_math.o build/temp.macosx-10.9-x86_64-cpython-39/build/src.macosx-10.9-x86_64-3.9/numpy/core/src/npymath/ieee754.o build/temp.macosx-10.9-x86_64-cpython-39/build/src.macosx-10.9-x86_64-3.9/numpy/core/src/npymath/npy_math_complex.o build/temp.macosx-10.9-x86_64-cpython-39/numpy/core/src/npymath/halffloat.o" failed with exit status 127
        [end of output]

    note: This error originates from a subprocess, and is likely not a problem with pip.
  error: legacy-install-failure

  × Encountered error while trying to install package.
  ╰─> numpy

  note: This is an issue with the package mentioned above, not pip.
  hint: See above for output from the failure.
  [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip. error: subprocess-exited-with-error

× pip subprocess to install build dependencies did not run successfully. │ exit code: 1 ╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

So, it failed again. I am so sorry for bothering so much.

With best regards, Li-Xin

stefmolin commented 1 year ago

The problem is clearly with the configuration on your machine, which I am not going to be able to solve for you. You will have to Google to figure out what system libraries you are missing, such that you can't even install packages. There seem to be some missing C dependencies and issues with openssl, from what we have seen so far.

Conda might be able to handle these for you if you remove the last 5 lines from the environment.yml file and then do this as suggested above:

Try deleting your environment and creating it this way: conda env create --file environment.yml

After that you would continue from step 3 above.

If you are not comfortable on the command line (which I'm inferring since you didn't want to use git clone), then I strongly recommend you use Binder, since fixing your local configuration will require a lot of Googling and using the command line to install missing system dependencies.

lxlofpku commented 1 year ago

@stefmolin Hi Stefanie:

This time I succeeded, I think. It appears that scikit-learn0.23.2 is not supported by Python3.9. I generated the book_env with Python3.8, then all 1-4 stepps went through successfully.

(I like to use command lines but I am just not farmiliar with git. I just bought a book om Git and am learning it.)

Best regards, Li-Xin

stefmolin commented 1 year ago

I just did a fresh install on an M1 Mac and version 0.23.2 of scikit-learn is available for Python 3.9 if you use conda. Often with older versions, conda is your best bet since it will handle the system dependencies that you may be missing. If you want to use pip, you have to hunt down what is missing. Anyway, I'm glad you got it to work.