I have python 2.7.13 for windows 7. I recently installed python 3.8 in a separate folder (c:\Python38).
I tried to install contextlib or paramiko modules, but i get the following error.
C:\Python38>pip install paramiko File "C:\Python38\Lib\site.py",
line 178 file=sys.stderr)
^
SyntaxError: invalid syntax
PYTHONPATH=C:\Python38;C:\Python38\Lib;C:\Python38\DLLs;C:\Python38\Lib\lib-tk
What am I missing? Thanks for your help.
I get the following error in Ubuntu 16.04 when I try to use commands like pip, pip3, pipenv, virtualenv:
ImportError: cannot import name '_remove_dead_weakref
I have both Python 2.7, Python 3.5, and Python 3.7 installed. When I type python in the command prompt I get this:
root#genopathngs-Precision-Tower-3620:/usr/local/bin# python File
"/usr/local/lib/python3.5/site.py", line 176
file=sys.stderr)
^ SyntaxError: invalid syntax
Please help me resolve this.
I've tried importing boto3 in python3 it's working, but i've tried boto3 in python2.7, it is throwing following error.
python3
Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 26 2016, 10:47:25)
>>> import boto3
>>> exit()
$ python
Python 2.7.10 (default, Oct 23 2015, 19:19:21)
>>> import boto3
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named boto3
How we can make boto3 to work with python2.7 ?
Notice that packages are not shared between python versions. If you install a package in your python3.x local version, it doesn't mean the package will be installed in your python2.x local version...
First of all do the following:
pip freeze
If boto3 package isn't there, great! install it:
pip install boto3
if it is there then verify what pip is being used and make sure to use the pip linking to your python2.x version:
which pip
you can create a symlink to use pip for python2.7... or even better, use pyenv to manage your python versions and virtualenv to isolate your workspace for a given python version.
https://github.com/yyuu/pyenv
https://virtualenv.pypa.io/en/stable/
As answered already pip install boto3 will resolve this error.
I would suggest using one version of Python (either 3 or 2) for your application.
Even if the OS relies on python2, your application can make use of python3.
Anyways, python2 EOL is 2020 - so python2 will slowly diminish.
I've created new virtual env and activated it. It is working good in New virtual env.
virtualenv path/to/my/virtual-env
source path/to/my/virtual-env/bin/activate
I recently tried to uninstall Python 3.5.2 and installed Python 3.6.0. I used to use python in the command line to run Python 3.5.2 from the command line, and py to run Python 2.7.12. Now, python runs Python 3.5.2, and py runs Python 3.6.0. I am running Windows 10, and python3, python2, py2, and py3 do not do anything.
Don't bother adding Python to the path. Just use:
py Run highest version of Python (override with PY_PTYHON environment variable).
py -2 Run highest version of Python 2.
py -3 Run highest verssion of Python 3.
py -2.7 Run Python 2.7.
py -2.7-32 Run python 2.7 32-bit when on a 64-bit system.
More: https://docs.python.org/3.6/using/windows.html#python-launcher-for-windows
Note you can also specify in scripts which version to use as well with, for example:
#!python2
#!python3
#!python2.7
I made a few experimentations upgrading from python 2.6.5 to python 2.7.11 in order to get Django to work properly. Then I had to uninstall python 2.7.11 and get back to python 2.6.5 (compatibility issues with other projects). Now, when I try to install django 1.2.1 using pip install django==1.2.1 I get this error:
C:\workspace\internal\trunk\ut_pr_01\src>pip install django==1.2.1
Downloading/unpacking django==1.2.1 Running setup.py egg_info for
package django
Traceback (most recent call last):
File "<string>", line 16, in <module>
File "c:\users\maxim\appdata\local\temp\pip-build\django\setup.py", line
32, in <module>
version = __import__('django').get_version()
File "c:\users\maxim\appdata\local\temp\pip-build\django\django\__init__.py",
line 3, in <module>
from django.utils.version import get_version
File "c:\users\maxim\appdata\local\temp\pip-build\django\django\utils\version.py",
line 7, in <module>
from django.utils.lru_cache import lru_cache
File "c:\users\maxim\appdata\local\temp\pip-build\django\django\utils\lru_cache.py",
line 28
fasttypes = {int, str, frozenset, type(None)},
^
SyntaxError: invalid syntax
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 16, in <module>
File "c:\users\maxim\appdata\local\temp\pip-build\django\setup.py",
line 32, in <module>
version = __import__('django').get_version()
File
"c:\users\maxim\appdata\local\temp\pip-build\django\django\__init__.py",
line 3, in <module>
from django.utils.version import get_version
File
"c:\users\maxim\appdata\local\temp\pip-build\django\django\utils\version.py",
line 7, in <module>
from django.utils.lru_cache import lru_cache
File
"c:\users\maxim\appdata\local\temp\pip-build\django\django\utils\lru_cache.py",
line 28
fasttypes = {int, str, frozenset, type(None)},
^
SyntaxError: invalid syntax
---------------------------------------- Command python setup.py egg_info failed with error code 1 in
c:\users\maxim\appdata\local\temp\pip-build\django Storing complete
log in C:\Users\Maxim\pip\pip.log
It seems like the version of python is what causing the problem but previously I installed any django with same pip and same python versions.
My environment currently:
pip 1.2.1,
python 2.6.5,
windows 10 64bit, needed django version: 1.2.1
Anyone with an idea?
You can have multiple version of Python installed on Windows (what you seem to be using) without any problems. You just have to make sure the default version of Python is set correctly for your situation.
Instead of using an extremely outdated version of django, install the latest version of Python - just choose a different path for it from the installer. So instead of C:\Python27 set it to C:\Python-27 or anything else.
If you are installing Python 3, you don't have to change the path since Python 3 installs itself in C:\Program Files (the default location for programs in Windows) and thus will not clash with Python 2 which installs directly onto the C:\ drive.
Once you have an updated version of Python installed, you just have to make sure that you call that version of Python when you need to install django. To do this effectively, use a Python virtual environment.
Lets assume you have installed the latest version of Python 2 in C:\Python-27, here is how you would install the latest version of django against it:
First, you need to install the virtualenv package. Open a command prompt and then type the following (the > is the prompt, don't type that):
> C:\Python-27\Scripts\pip.exe install virtualenv
A few minutes later you should have virtualenv installed, next step is to install django inside a new virtual environment:
> C:\Python-27\Scripts\virtualenv.exe C:\%USER%\Desktop\django-env
Once that is done, you need to activate the environment, and install django:
> C:\%USER%\Desktop\django-env\bin\activate.bat
(django-env) > pip install django
Now you have the latest version of django installed on an updated version of Python.
Managing these environments can be difficult; so I would suggest downloading a Python IDE. PyCharm is what I use and there is a free community version available. It will make it easy to manage all the different versions of Python for you.
Python 2.6 does not have set literals.
# in python 2.6 only this will work
fasttypes = set(int, str, frozenset, type(None))
# in python 2.7+ this will work as well
fasttypes = {int, str, frozenset, type(None)}
The version of Django you are using is not compatible with python 2.6.5
Support for Python 2.6 was dropped in Django 1.7, so I'm not sure why you get this error when you try to install Django 1.2.1. Maybe a more recent version is residing in the temp\pip-build\ directory. Since it's called temp it should be safe to delete that directory.
In any case, Python 2.6 and the corresponding Django versions are insecure and unsupported. I highly recommend using a current version instead. If other projects need old deprecated Python versions, you should use virtual environments to isolate them.
The problem was solved by installing the Django version I need - 1.2.1 not using pip but downloading the files and manually running:
python setup.py install .