Error occurred after updating and changing PYTHONHOME variable - python

After changing some environmental variable for PYTHONHOME and updating pycharm and python my console kept spitting out this error:
def __new__(mcls, name, bases, namespace, /, **kwargs)
^
SyntaxError: invalid syntax
I've search through some similar problems and tried to reinstall python and let it set the path but the problem still occurred.
For reference my first error that lead to this was akin to what happened int his question: Fatal Python error on Windows 10 ModuleNotFoundError: No module named 'encodings'.
Then i tried the solution in this question: Fatal Python error: init_sys_streams: can't initialize sys standard streams AttributeError: module 'io' has no attribute 'OpenWrapper'
And now i found myself with the above error of which am at a standstill. Ive tried looking for the syntax one would use for this new and perhaps found the error in there but so far no good.
Edit 1: Removed a / from _py_abc.py and it now says ImportError: cannot import name 'open_code'

I've got the same error after I've installed and tried to use python 3.8 in eclipse.
The exact line of code is inside the _py_abc.py module/file, and it contains a feature that was introduced in python3.8, the positional only parameters.
In my case, the error was raised while pylint (which was installed with pip2/python2) was trying to ... lint, and persisted even after I've installed pylint with pip3/python3 (which in my Ubuntu 18.04 WSL points to python3.6). I've managed to overcome the problem only after I've installed pylint explicitly with python3.8.
So, this whole ranting about pylint is only to explain how I got the error and how I understood the problem which basically is: some thing inside the IDE is trying to use some pre-3.8 executable to run something that should be run with a python3.8+ executable.

Related

Error when importing Dialogflow in Python

I downloaded a project in which dialogflow is used, from a repo. However, it showed an error on my pycharm "run". The error itself says
django.core.exceptions.ImproperlyConfigured: The included URLconf 'quiniela.urls' does not appear to have any patterns in it.
But I have had that error show on my pycharm even when the error has nothing to do with it. For instance, if I make an integer variable and try to print it, it would show that exact error, which clearly isn't it, the error would be not casting the integer and trying to print it. So, what I'm saying is, that error appears when ANY error exists, so I usually ignore it and that's my problem to fix later, but that's not this question.
I tracked the error, and found that whenever I comment the line import dialogflow (and every line that uses dialogflow) in my views.py, the error disappears. If I uncomment just that import dialogflow, again it fails. Why would that be? If I go to interpreter settings, I see that the package dialogflow is installed, and if I try to install it, it says it's already installed, so that is not the problem.
Why do you think it could fail to import dialogflow? The dialogflow version is 0.7.2, and the python version is 3.6, and I'm using Windows 10.

Paraview: paraview.simple import, all paths are set

I am trying to run a simple python program, importing the paraview.simple module:
from paraview.simple import *
I get the following error:
Error: Could not import vtkCommonComputationalGeometry
I looked at similar posts on different fora and tried everything that was suggested there, but nothing worked for me. My Python path includes:
ParaView-5.7.0-MPI-Linux-Python2.7-64bit/bin/
ParaView-5.7.0-MPI-Linux-Python2.7-64bit/lib
ParaView-5.7.0-MPI-Linux-Python2.7-64bit/lib/python2.7/site-packages/
My LD_LIBRARY_PATH includes:
ParaView-5.7.0-MPI-Linux-Python2.7-64bit/lib/python2.7/site-packages/vtkmodules/
Does anybody know how to fix it?
Update:
I think there is an underline issue regarding the Unicode variant my python interpreter is using. I now get the following error:
Unicode error
ImportError: /home/nick/ParaView-5.7.0-MPI-Linux-Python2.7-64bit/lib/python2.7/site-packages/vtkmodules/vtkCommonCorePython.so: undefined symbol: PyUnicodeUCS2_DecodeUTF8
Does anybody know a fix?
You may want to use the pvpython program that is bundled with ParaView. It is basically a python interpreter but already setup with the correct paths.
If you want to use an external interpreter, you have to setup the PYTHONPATH environment variable to ParaView-5.7.0-MPI-Linux-Python2.7-64bit/lib/python2.7/site-packages/ and the LD_LIBRARY_PATH (on linux, PATH on windows) to ParaView-5.7.0-MPI-Linux-Python2.7-64bit/lib.
See also the ParaViewTutorial pdf from the download page (https://www.paraview.org/download/), at 3.1 Starting the Python Interpreter

Importing winappdbg gives ModuleNotFoundError for breakpoint in PyCharm?

Whenever I try to just import winappdbg it gives me an error ModuleNotFoundError: No module named 'breakpoint'. So, I tried installing breakpoint and that gives me another error ModuleNotFoundError: No module named 'ConfigParser' and I've installed configparser several times and still get the error. (Can't find capital ConfigParser) I'm using Windows 10/PyCharm Community Edition 2017.2.3/python 3.6.3
WinAppDbg is only for Python 2.x, it does not work on Python 3.x. Honestly, I had no idea it would even let you import it.
All those import errors are happening not because of missing dependencies (also, no idea there were similarly named modules in pip), they are submodules of WinAppDbg itself. Since Python 3 has a different syntax to specify those, it tries to load them as external modules instead. I suppose you could fix that in the sources by prepending a dot before every submodule import, but I'm guessing more stuff would break down the road (string handling for example is radically different and that would affect the ctypes layer).
TL;DR: use Python 2.x.

import error: ephem/_libastro.so undefined symbol: PyUnicodeUCS2_AsUTF8String

I just successfully installed PyEphem using pip in a pyenv. However, on import I receive:
ImportError: /python2.7/site-packages/ephem/_libastro.so: undefined symbol: PyUnicodeUCS2_AsUTF8String
In looking around I've seen it mentioned that some modules are built "against Python" in regards to Unicode and suggest recompiling. I'm quite new to Python and Ubuntu 14.04, and although I believe this is the answer to my issue, I do not know what recompiling means or how to do it.
The symbol PyUnicode_AsUTF8String(value) is used once in _libastro.c and is defined on my system in the file:
/usr/include/python2.7/unicodeobject.h
There it can be aliased one of two ways:
#ifndef Py_UNICODE_WIDE
# ...
# define PyUnicode_AsUTF8String PyUnicodeUCS2_AsUTF8String
# ...
#else
# ...
# define PyUnicode_AsUTF8String PyUnicodeUCS4_AsUTF8String
Your error message makes it sound as though your system Python is compiled to use 4-byte-wide Unicode strings (hence why the linker cannot find a UCS2 version of this function inside of it), but that the version of PyEphem that auto-compiled on your system when you ran pip install somehow got confused and unset Py_UNICODE_WIDE and thus generated C code that was expected a UCS2 symbol.
Do you have several compiled versions of Python on your system, where the Unicode setting of one version could accidentally be affecting how this compile for your system Python takes place?

Import Error: Using Python with Geany

How can I add path to the PYTHONPATH environment variable
I tried using "sudo so" in .bash and also tried
export PYTHONPATH=$PYTHONPATH:/home/01_Understand/scitools/bin/linux32/python
but I am still getting import error.
I actually want to use Understand module (understand.py) with Geany but there is always an error stating
ImportError: No module named understand
Can anyone help me in this regard ?
Thanks

Categories