简体   繁体   中英

Cannot download any Python Library

I am facing a huge problem.

I cannot manage to download any library for Python 3. I am trying to use a virtual environment as well. I am using Visual Studio Code.

I upgraded pip to the latest version and made sure to remove any restriction for running scripts on my laptop. Now, when I run python -m pip install {package name} , it always shows a warning and a bunch of red text. Here's the output (which I totally don't understand) when I tried downloading the novas library:

WARNING: Discarding https://files.pythonhosted.org/packages/6c/6f/9c11a148e744fc9450af3b316c52f5ff0fe3d86e6b4885f3b82aeb67d4f8/novas-3.1.1.tar.gz#sha256=0e120c325c6d96ad6790d7ebf58231bbb4d22ed0d4ec2d1ce72465598989e2d7 (from https://pypi.org/simple/novas/). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
  Using cached novas-3.1.tar.gz (131 kB)
  Preparing metadata (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: 'C:\Users\Name\Desktop\python_projects\project_1\venv\Scripts\python.exe' -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Name\\AppData\\Local\\Temp\\pip-install-pzup5zic\\novas_e22cf354aee142d29041b8892b3ff6f8\\setup.py'"'"'; __file__='"'"'C:\\Users\\Name\\AppData\\Local\\Temp\\pip-install-pzup5zic\\novas_e22cf354aee142d29041b8892b3ff6f8\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\Name\AppData\Local\Temp\pip-pip-egg-info-_6kpy5wd'
       cwd: C:\Users\Name\AppData\Local\Temp\pip-install-pzup5zic\novas_e22cf354aee142d29041b8892b3ff6f8\
  Complete output (8 lines):
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "C:\Users\Name\AppData\Local\Temp\pip-install-pzup5zic\novas_e22cf354aee142d29041b8892b3ff6f8\setup.py", line 10, in <module>
      from asc2eph import *
    File "C:\Users\Name\AppData\Local\Temp\pip-install-pzup5zic\novas_e22cf354aee142d29041b8892b3ff6f8\asc2eph.py", line 15
      print "Retrieving list of ephemeris files"
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
  ----------------------------------------

Please, any help will be most welcomed

Have you tried python3 -m pip install {package} ? It seems your SO is trying to use a Python 2 version..

As we can see the error on last line

SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?

its calling print without (paranthsis), means that its using old version of Python 2.x and that script is now deprecated. Now, all you can do is to specify the python version in the terminal just like:

python3 -m pip install {package name}

or

pip3 install {package name}

or

pip install {package name}

I hope all of the above commands will work fine.

For some reason your pip is trying to install a novas version from 2012:

Using cached novas-3.1.tar.gz (131 kB)

Which is not compatible with python3. You can try to specify the latest version:

pip install novas==3.1.1.5

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM