Error installing packages(Numpy) on older version of python - python

I'm trying to run code from a repository from 2016 that doesn't label what versions of anything it's using, but I think I figured out that it was using Python version 3.4. I went ahead and installed that python version, but when I went to install the dependencies, starting with Numpy, I got this error when running
pip install numpy
The error is as follows
SyntaxError: invalid syntax
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 17, in <module>
File "C:\Users\sam\AppData\Local\Temp\pip_build_sam\numpy\setup.py", line 64
raise RuntimeError(f'Cannot parse version {FULLVERSION}')
^
SyntaxError: invalid syntax
Not sure what to do. My machine is a windows-10-64bit Python version is 3.4.0 and pip version is 1.5.4. If anyone cares to see if there's a more holistic way to get this code to run, this is the repo. https://github.com/czhuang/ChordRipple

The setup script for the version of Numpy you're trying to install is using an f-string. However, f-strings were introduced in Python 3.6, so your version does not support this. Installing an older version of numpy should work. Version 1.15.4 should be the latest one that supports Python 3.4.
pip install numpy==1.15.4 should do the trick.

Related

Installing Pip but require setuptools and getting syntax error

Trying to install pip without internet, so I downloaded the tar.gz package from pypi.org and when installing the pip setup file by running "python setup.py install" I get "No Module Named 'Setuptools'".
So I downloaded setuptools.tar.gz from pypi.org and ran the "python setup.py install" but this time I get a syntax error. Python version running is 3.5.2.
Traceback (most recent call last):
File "setup.py", line 7, in <module>
import setuptools
File "/home/insite/setuptools-57.0.0/setuptools/__init__.py", line 18, in <module>
from setuptools.dist import Distribution
File "/home/insite/setuptools-57.0.0/setuptools/dist.py", line 585
license_files: Optional[List[str]] = self.metadata.license_files
^
SyntaxError: invalid syntax
It looks like you're trying to install setuptools 57.0.0 on Python 3.5. As of setuptools 51.0.0,
Breaking Changes
#2435: Require Python 3.6 or later.
You need a version of setuptools that's 50.0.0 or older.
For what it's worth, the specific error you're getting is because of PEP 526, which was added to Python officially in 3.6. But even if you patched that somehow (and I don't recommend trying), you're likely to run into other problems. You just need an older setuptools or a newer Python.
Wrong setuptools version was used. Python 3.5 uses setuptools version 50.0.0 or older. Thanks to Silvio Mayolo.

Installing hashLib gives SyntaxError: Missing parentheses in call to 'print'

I needed a simple hash function for passwords and thought I could use hashlib. PyCharm suggested to install it by running pip install hashLib.
But now PyCharm is complaining about a syntax error in the library:
Collecting hashLib
Using cached https://files.pythonhosted.org/packages/74/bb/9003d081345e9f0451884146e9ea2cff6e4cc4deac9ffd4a9ee98b318a49/hashlib-20081119.zip
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/6_/8g1vyy5n1t1859x2d30ssk480000gn/T/pycharm-packaging/hashLib/setup.py", line 68
print "unknown OS, please update setup.py"
^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print("unknown OS, please update setup.py")?
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/6_/8g1vyy5n1t1859x2d30ssk480000gn/T/pycharm-packaging/hashLib/
It suggests that it may be a problem related to the Python version I am using (I tried with Python 2.7 and Python 3.8, but none of them worked).
Make sure that you use a version of Python supported by this package.
Currently you are using Python 3.8.
hashlib is in the standard library now. That means you don't need to install it, it's there already with your Python installation.
The one you tried to install from PyPI is for very old versions of Python (<= 2.4).

Why do I have problems loading a module in Python3 but not in Python2?

Depending on which installation of Python I am using I have some problems to load a module. When I type
from quantecon import approx_markov
in the terminal using Python 3.4.0, the following error message is returned:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.4/dist-packages/quantecon/__init__.py", line 6,in <module>
from asset_pricing import AssetPrices
ImportError: No module named 'asset_pricing'
In the folder /usr/... as referred to above, I do however find a module called asset_pricing. (I have to admit that I additionally do not understand why the module asset_pricing interferes.)
I installed quantecon with:
pip3 install quantecon
I suspect that the problems are related to the Python version I am using. I also installed
pip install quantecon
and when I call the module approx_markov form the terminal, using Python 2.7.6 (I think this is the standard Python version of the OS I am using) I do not receive any error message. To solve the problem I already followed the instruction in the following discussion but to no avail Python3 has no acces to python2 modules (ubuntu).
The currently released version of quantecon is not Python 3 compatible; it uses relative imports and these are not supported anymore in Python 3.
The version in the source repository has been refactored and updated, and looks like it'll work with Python 3. You'll need to install that version instead:
pip3 install -U git+https://github.com/jstac/quant-econ.git
where -U tells pip3 to upgrade the package.
Note that there have been a lot of changes recently; use at your own risk. You could stick with Python 2 and wait for an official release.

Problems with Python package installation, versioning

I am using Python 2.7.4. Works fine for web development and everything that doesn't require the use of specific packages.
But every time I am trying to install and use a new package, I get an error.
Example:
Cloned https://github.com/fatiherikli/worldcup
install worldcup was successful (python-dateutil, colorama, pytz, humanize)
But
$ worldcup today
Traceback (most recent call last):
File "/usr/local/bin/worldcup", line 8, in <module>
load_entry_point('worldcup==1.0.3', 'console_scripts', 'worldcup')()
File "/Library/Python/2.6/site-packages/worldcup.py", line 129, in main
print prettify(match)
File "/Library/Python/2.6/site-packages/worldcup.py", line 45, in prettify
seconds = diff.total_seconds()
AttributeError: 'datetime.timedelta' object has no attribute 'total_seconds'
My python version is 2.7 not 2.6:
$ python --version
Python 2.7.4
Any suggestion?
From the path names it appears you are running on a version of Mac OS X, which comes with multiple builtin versions of Python and you have likely installed a newer version of Python 2.7. Chances are you have installed a version of pip for your system Python 2.6 but not for the Python 2.7 that worldcup requires. You can easily check this by typing:
python2.7 -m pip install worldcup
If pip is not available for that instance of Python you'll need to install it by downloading get-pip.py and running it with python2.7.

running pip install from python 2.7.5

I have a CentOS server (5.6) which has Python 2.4.3 on it. I have another local installation of Python (2.7.5) installed in /opt and soft-links created as follows /usr/local/bin/python2.7 and /usr/local/python2.7. I want to install python-requests using pip. While installing using the command pip install requests, I get the following error:
root ~/ff_test_ff # pip install requests
Unpacking ./requests
Running setup.py egg_info for package from file:///root/ff_test_ff/requests
Traceback (most recent call last):
File "<string>", line 14, in ?
File "/tmp/pip-MM685m-build/setup.py", line 6, in ?
import requests
File "requests/__init__.py", line 58
from . import utils
^
SyntaxError: invalid syntax
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 14, in ?
File "/tmp/pip-MM685m-build/setup.py", line 6, in ?
import requests
File "requests/__init__.py", line 58
from . import utils
^
SyntaxError: invalid syntax
----------------------------------------
Command python setup.py egg_info failed with error code 1
Storing complete log in /root/.pip/pip.log
I'm assuming it's still trying to use Python 2.4. I checked here which says 2.4 isn't supported. So how do I run the pip install command but use python2.7 instead?
you need to set the PYTHONPATH / PYTHONHOME like here
you can also try to install virtualenv
You probably should (re)install a new version of pip explicitly for the new Python version. On pip installation instructions page it says that
pip works with CPython versions 2.6, 2.7, 3.1, 3.2, 3.3 and also pypy.
While installing, be sure to use the newer version of Python instead of the old one.

Categories

Resources