problem running scons - python

I am trying to get started with scons. I have Python 3.0.1 and downloaded Scons 1.2.0; when I try to run scons I get the following error. Am I doing something wrong here?
C:\tmp\scons>c:\appl\python\3.0.1\Scripts\scons
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "c:\appl\python\3.0.1\Lib\site-packages\scons-1.2.0\SCons\__init__.py", l
ine 43, in <module>
import SCons.compat
File "c:\appl\python\3.0.1\Lib\site-packages\scons-1.2.0\SCons\compat\__init__
.py", line 208
raise Error, "Cannot move a directory '%s' into itself '%s'." % (src, dst)
^
SyntaxError: invalid syntax

That's Python 2 syntax. I assume scons doesn't run on Python 3. You need to run it using Python 2.

Related

How to solve "NameError: name 'basestring' is not defined" when importing psycopg2?

I am trying to import the psycopg2 package on python 3.7.13 but I get the following error:
python -c "import psycopg2" % 11:22:56
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/Users/mm/.pyenv/versions/3.7.13/lib/python3.7/site-packages/psycopg2/__init__.py", line 68, in <module>
from psycopg2 import extensions as _ext
File "/Users/mm/.pyenv/versions/3.7.13/lib/python3.7/site-packages/psycopg2/extensions.py", line 211, in <module>
from psycopg2. _range import Range # noqa
File "/Users/mm/.pyenv/versions/3.7.13/lib/python3.7/site-packages/psycopg2/_range.py", line 503, in <module>
oid=3904, subtype_oid=23, array_oid=3905)
File "/Users/mm/.pyenv/versions/3.7.13/lib/python3.7/site-packages/psycopg2/_range.py", line 283, in __init__
self._create_ranges(pgrange, pyrange)
File "/Users/mm/.pyenv/versions/3.7.13/lib/python3.7/site-packages/psycopg2/_range.py", line 302, in _create_ranges
if isinstance(pgrange, basestring):
NameError: name 'basestring' is not define
I am wondering how can I solve it ?
I already tried downgrading pip to 20.3 after seeing this issue https://github.com/psycopg/psycopg2/issues/1419.
Resolved this by manually transforming psycopg2 package to a python 3 compatible version running:
pip install 2to3
2to3 ~/.pyenv/versions/3.7.13/lib/python3.7/site-packages/psycopg2/ -w
Still have no idea why this error occured though.

SyntaxError: invalid syntax when creating virtualenv

I wanted to create a virtualenv for python 2.7 (I'm using 3.7)
I run the cmd as admin (on windows 10) :
C:\WINDOWS\system32>virtualenv -p C:\Python27\python.exe py27
An I got the error:
Running virtualenv with interpreter C:\Python27\python.exe
Traceback (most recent call last):
File "c:\path\to\virtualenv.py", line 26, in <module>
import logging
File "C:\Python27\lib\logging\__init__.py", line 43, in <module>
import threading
File "C:\Python27\lib\threading.py", line 15, in <module>
from collections import deque
File "C:\Python27\lib\collections\__init__.py", line 55
raise AttributeError(f'module {__name__!r} has no attribute {name!r}')
^
SyntaxError: invalid syntax
When I Launch Python2.7 and try to import the logging module: It show the same error but When I retype it. It work just fine:
>>> import logging
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\logging\__init__.py", line 43, in <module>
import threading
File "C:\Python27\lib\threading.py", line 15, in <module>
from collections import deque
File "C:\Python27\lib\collections\__init__.py", line 55
raise AttributeError(f'module {__name__!r} has no attribute {name!r}')
^
SyntaxError: invalid syntax
>>> import logging
>>> logging.warning('hello word')
WARNING:root:hello word
>>>
I can't figure out why it does that.
I have already configured a virtual env with python 3.6
Any help would be appreciated.
You have a version problem. This line
raise AttributeError(f'module {__name__!r} has no attribute {name!r}')
is being run under Python 2.7, but is Python 3.6 (or 3.7) and will give you a syntax error in earlier versions. In your case I would treat that Python 2.7 installation as irretrievably broken, because it is clear that the standard library isn't to be trusted to all be of a consistent version.
The problem was resolved deleting the c:\Python27 directory, Then Uninstalling python 2.7 using the setup tool, restarting the computer and reinstalling Python 2.7

pywin32 RuntimeError: Can't find the Windows SDK

Execute "python setup3.py install" reported this error
I am searching for a long time on net. But no use. Please help or try to give some ideas how to achieve this.
D:\Software Package\pywin32-master\pywin32-master>python setup3.py install
Converting...
Executing...
Building pywin32 3.6.221.0
Traceback (most recent call last):
File "setup3.py", line 16, in <module>
exec(str(got))
File "<string>", line 305, in <module>
RuntimeError: Can't find the Windows SDK
D:\Software Package\pywin32-master\pywin32-master>python setup.py install
File "setup.py", line 127
print "Building pywin32", pywin32_version
^
SyntaxError: Missing parentheses in call to 'print'

python-3.5.1: unable to 'make' on mipsel

I am trying to install python-3.5.1 on mipsel. Initially while doing 'make' it gave me syntax error in graminit file, so i gave it the path of graminit.h of another python-3.5.1 (which was compiled for ubuntu 14.04 or say x86 platform).Later same happened for my importlib module (again i did the same).And now it is giving me syntax invalid as:-
Failed to import the site module
Traceback (most recent call last):
File "./Lib/site.py", line 72, in <module>
import os
File "./Lib/os.py", line 666, in <module>
from _collections_abc import MutableMapping
File "./Lib/_collections_abc.py", line 56
async def _coro(): pass
^
SyntaxError: invalid syntax
make: *** [sharedmods] Error 1

Can't get pywin32-219 to work with python 3.5

It seems to install without error using the EXE (in my case pywin32-219.win-amd64-py3.5.exe) however when run the python interpreter and try to "import win32api" I get the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: DLL load failed: The specified module could not be found.
If I download the zip file and try to run "setup3.py install" I get the following output:
Converting...
Executing...
Building pywin32 3.5.219.0
Traceback (most recent call last):
File "setup3.py", line 16, in <module>
exec(str(got))
File "<string>", line 1929, in <module>
File "<string>", line 587, in __init__
File "C:\Python35\lib\ntpath.py", line 113, in join
genericpath._check_arg_types('join', path, *paths)
File "C:\Python35\lib\genericpath.py", line 143, in _check_arg_types
(funcname, s.__class__.__name__)) from None
TypeError: join() argument must be str or bytes, not 'NoneType'
I've tried a couple of things but cant get it to work.
Has anyone gotten pywin32 to install and work correctly with python 3.5?
You need to run the pywin installer with elevated permissions as it writes to the system32 folder. If you didn't run with elevated permissions, open an admin cmd prompt and run the postinstall script in the pywin install directory.
The compiling from source error is related to pywin32 not catching an error that ends up crashing everything. Specifically line 587 of setup.py causes a crash if sdk_dir is None.
Changing line 587 to
if sdk_dir and os.path.isfile(os.path.join(sdk_dir, "include", "activdbg.h")):
prevents that crash, but my installation later crashes with the following error:
win32/src/win32wnet/PyNetresource.cpp(120): error C2440: 'initializing':
cannot convert from 'int (__cdecl *)(PyObject *,PyObject *)' to 'PyAsyncMethods *'win32/src/win32wnet/PyNetresource.cpp(120): note: There is no context in which this conversion is possible
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\cl.exe' failed with exit status 2

Categories