I am trying to use Emacs as my Python IDE under win32. I referred to several posts on the Internet and I had yasinppet, auto-complete, pymacs, ropemacs installed on my Emacs. It shows that Emacs will load python mode, rope mode, yas mode and auto-complete mode after I create a *.py file. But I got an error saying that the system cannot find pymacs.py file when I tried to use functions like "Goto definition" (C-c g) of rope. I am quite sure I have installed pymacs correctly and the path is right. So anyone can help me out of this?
WindowsError: [Error 3] The system cannot find the path specified:
Traceback (most recent call last):
File "C:\\Python27\\Pymacs\\Pymacs\\pymacs.py", line 265, in loop
value = eval(text)
File "<string>", line 1, in <module>
UnicodeDecodeError: \'ascii\' codec can\'t decode byte 0xe5 in position 12:
ordinal not in range(128)
Related
I have Windows 10 x64 en-US and Anaconda3 2021.05. My anaconda prompt was working. Today it failed to launch and shows an error:
# >>>>>>>>>>>>>>>>>>>>>> ERROR REPORT <<<<<<<<<<<<<<<<<<<<<<
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\site-packages\conda\cli\main.py", line 140, in main
return activator_main()
File "C:\ProgramData\Anaconda3\lib\site-packages\conda\activate.py", line 1210, in main
print(activator.execute(), end='')
File "C:\ProgramData\Anaconda3\lib\site-packages\conda\activate.py", line 178, in execute
return getattr(self, self.command)()
File "C:\ProgramData\Anaconda3\lib\site-packages\conda\activate.py", line 153, in activate
return self._finalize(self._yield_commands(builder_result), self.tempfile_extension)
File "C:\ProgramData\Anaconda3\lib\site-packages\conda\activate.py", line 143, in _finalize
tf.write(self.command_join.join(commands))
File "C:\ProgramData\Anaconda3\lib\tempfile.py", line 473, in func_wrapper
return func(*args, **kwargs)
UnicodeEncodeError: 'utf-8' codec can't encode character '\udd8e' in position 952: surrogates not allowed
`$ C:\ProgramData\Anaconda3\Scripts\conda-script.py shell.cmd.exe activate C:\ProgramData\Anaconda3`
Anaconda PowerShell Prompt also fails to launch with similar error:
# >>>>>>>>>>>>>>>>>>>>>> ERROR REPORT <<<<<<<<<<<<<<<<<<<<<<
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\site-packages\conda\cli\main.py", line 140, in main
return activator_main()
File "C:\ProgramData\Anaconda3\lib\site-packages\conda\activate.py", line 1210, in main
print(activator.execute(), end='')
UnicodeEncodeError: 'utf-8' codec can't encode character '\udd8e' in position 954: surrogates not allowed
`$ C:\ProgramData\Anaconda3\Scripts\conda-script.py shell.powershell activate C:\ProgramData\Anaconda3`
I searched around and tried everything, including:
Uninstall and reinstall Anaconda.
Upgrade Python to the latest version.
Add PYTHONIOENCODING=utf8 to environment variables.
Add "C:\ProgramData\Anaconda3" and "C:\ProgramData\Anaconda3\Scripts" to PATH.
Removing tempfile.py.
etc., couldn't fix it.
I searched this \udd8e character:
This is an unassigned character within a valid range, meaning it could be designated a valid Unicode code point in the future. However, for now it has no assigned value.
How could I fix this? Thank you very much.
The issue is a non-unicode letter in you PATH environment, which has to be deleted.
Go to your PATH environment file (control panel > system > advanced settings > environment variables) and delete paths under your local user account with non-unicode letters in it.
I had a similar error where setting the PYTHONIOENCODING=utf8 environment variable didn't work, but setting PYTHONUTF8=1fix it.
I have:
a file file.txt containing just one character: ♠, and UTF-8 encoded.
a CP-1252 encoded Python script test.py containing:
import codecs
text = codecs.open('file.txt', 'r', 'UTF-8').read()
print('text: {0}'.format(text))
When I run it in Eclipse 4.7.2 on Windows 7 SP1 x64 Ultimate and with Python 3.5.2 x64, I get the error message:
Traceback (most recent call last):
File "C:\eclipse-4-7-2-workspace\SEtest\test.py", line 3, in <module>
print('text: {0}'.format(text))
File "C:\programming\python\Python35-32\lib\encodings\cp1252.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\u2660' in position 6: character maps to <undefined>
My understanding is that the issue stems from the fact that on Microsoft Windows, by default the Python interpreter uses CP-1252 as its encoding and therefore has is with the character ♠.
Also, I would note at that point that I kept Eclipse default encoding, which can be seen in Preferences > General > Workspace:
When I change the Python script test.py to:
import codecs
print(u'♠') # <--- adding this line is the only modification
text = codecs.open('file.txt', 'r', 'UTF-8').read()
print('text: {0}'.format(text))
then try to run it, I get the error message:
(note: Eclipse is configured to save the script whenever I run it).
After selecting the option Save as UTF-8, I get the same error message:
Traceback (most recent call last):
File "C:\Users\Francky\eclipse-4-7-2-workspace\SEtest\test.py", line 2, in <module>
print(u'\u2660')
File "C:\programming\python\Python35-32\lib\encodings\cp1252.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\u2660' in position 0: character maps to <undefined>
which I think is expected since the Python interpreter still uses CP-1252.
But if I run the script again in Eclipse without any modification, it works. The output is:
♠
text: ♠
Why does it work?
Phyton converts the text to be printed to the encoding of the console which is the active code page on Windows (at least until version 3.6).
To avoid the UnicodeEncodeError you have to change the console encoding to UTF-8. There are several ways to do this, e. g. on the Windows command line by executing cmd /K chcp 65001.
In Eclipse, the encoding of the console can be set to UTF-8 in the run configuration (Run > Run Configurations...), in the Common tab.
The text file encoding settings in Window > Preferences: General > Workspace and in Project > Properties: Ressource are only used by text editors how to display text files.
I have two python scripts where one needs to be run using the older version of python (2.7) and other in the newer version i.e. 3.6. So I created two environments in Anaconda- one with python 2.7.8 (old) and the other with Python 3.6 (new). I am using a data files say “test_input.csv” and “test_input.sig”.
I am able to run the first script file in the python 2.7.8 environment which basically preprocess the data i.e. unwrapping categorical variables, normalizing the variables, etc and dumps it into a pickle. So, it generated the “test_input.csv_normalized.pickle” file. But now when I am trying to run the second script in python 3.6 in Anaconda where I am trying to load this pickle file i.e.
import numpy as np
y=np.load('test_input.csv_normalized.pickle')
But here I am getting the following error:-
File "/..../python3.6/site-packages/numpy/lib/npyio.py", line 413, in
load return pickle.load(fid, **pickle_kwargs)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xea in position
0: ordinal not in range(128) During handling of the above exception,
another exception occurred:
Traceback (most recent call last): File
"ClusterId.py", line 84, in
y=np.load('test_input.csv_normalized.pickle') File
"/home/putatund/anaconda3/lib/python3.6/site-packages/numpy/lib/npyio.py",
line 416, in load "Failed to interpret file %s as a pickle" %
repr(file))
OSError: Failed to interpret file
'test_input.csv_normalized.pickle' as a pickle
Any idea what might be the issue? And how to resolve this.
When trying to install mysql-python on my Windows 10 machine i get the following error:
File "<string>", line 1, in <module>
File "C:\Users\LUCAFL~1\AppData\Local\Temp\pip-build-3u7aih0l\mysql-python\setup.py", line 21, in <module>
setuptools.setup(**metadata)
File "c:\program files (x86)\python35-32\lib\distutils\core.py", line 148, in setup
dist.run_commands()
...
File "c:\program files (x86)\python35-32\lib\subprocess.py", line 1055, in communicate
stdout = self.stdout.read()
File "c:\program files (x86)\python35-32\lib\encodings\cp1252.py", line 23, in decode
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 1716: character maps to <undefined>
I tried installing other packages and received the same error on almost every one (one exception being pymysql). All of these packages were big and had dependencies. I guess that the big ones create temporary data in my user directories APPDATA folder. As you can see, the ü is not properly decoded (ü being byte 0x81). It's always a german umlaut that produces the error (mainly ü, as it's part of my user folders name).
I googled for the last 2 hours and found a lot of people having the same problem, but mostly they were opening github tickets or discussing the problem for Ubuntu/Fedora/OSX, etc. A couple times i read, that the standard encoding under windows is cp-1252 which causes the problem. Can i somehow force windows using my console to use utf-8 for this session and then run pip with that?
Please don't recommend me renaming my user folder. It's not easily done under Windows 10 and i dont want to re-install windows just because of python.
My setup: Windows 10, Python 3.5.1, pip 8.0.3
Can you try the following and see if it works. Replace path for python by your actual path.
I am not able to simulate on my windows laptop.
import sys
import subprocess
reload(sys) # Reload may do the trick!
sys.setdefaultencoding('UTF8')
theproc =subprocess.call(['C:\\Python27\\Scripts\\pip.exe', 'install', 'mysql-python'])
theproc.communicate()
Trying to create a Python application on ElasticBeanstalk using the CLI, after I select my platform version I get the following error:
Select a platform version.
1) Python 3.4
2) Python
3) Python 2.7
4) Python 3.4 (Preconfigured - Docker)
(default is 1): 1
ERROR: UnicodeDecodeError :: 'ascii' codec can't decode byte 0xe2 in position 891: ordinal not in range(128)
I found this: https://github.com/aws/aws-cli/issues/708 which makes me think maybe I pasted my AWS credentials with a newline attached. I'd like to re-enter the credentials but it seems they are cached somewhere (it asked me for them on the first install attempt but not any subsequence attempts). I do not see them in my environment vars and I have been deleting .elasticbeanstalk between attempts. Any ideas?
update: I deleted .aws/config so it allowed me to re-enter my credentials. Still get the same error when I try to run eb init
update2: gist of --debug output can be found here: https://gist.github.com/dshuhler/8d64849021c48bf1ba71
tldr; My .gitignore had a hidden non-ascii character as I had copy pasted a Python specific .gitignore from a popular Github repository.
Steps I took to figure out the root cause
So, I couldn't find any answer that helped me solve this problem for me. Looks like, different people are seeing this error for different reasons.
I'm going to share the steps I took to figure out the cause for my problem. Make sure to run your command using --debug flag
$ eb init --debug
My output was something like this
2019-05-05 13:44:17,548 (INFO) eb : Traceback (most recent call last):
File "/Users/mudassirali/.virtualenvs/rtp_dev/lib/python3.6/site-packages/ebcli/core/ebrun.py", line 62, in run_app
app.run()
File "/Users/mudassirali/.virtualenvs/rtp_dev/lib/python3.6/site-packages/cement/core/foundation.py", line 797, in run
return_val = self.controller._dispatch()
File "/Users/mudassirali/.virtualenvs/rtp_dev/lib/python3.6/site-packages/cement/core/controller.py", line 472, in _dispatch
return func()
File "/Users/mudassirali/.virtualenvs/rtp_dev/lib/python3.6/site-packages/cement/core/controller.py", line 478, in _dispatch
return func()
File "/Users/mudassirali/.virtualenvs/rtp_dev/lib/python3.6/site-packages/ebcli/core/abstractcontroller.py", line 89, in default
self.do_command()
File "/Users/mudassirali/.virtualenvs/rtp_dev/lib/python3.6/site-packages/ebcli/controllers/initialize.py", line 118, in do_command
initializeops.setup(app_name, region_name, platform, dir_path=None, repository=repository, branch=branch)
File "/Users/mudassirali/.virtualenvs/rtp_dev/lib/python3.6/site-packages/ebcli/operations/initializeops.py", line 57, in setup
setup_ignore_file()
File "/Users/mudassirali/.virtualenvs/rtp_dev/lib/python3.6/site-packages/ebcli/operations/initializeops.py", line 92, in setup_ignore_file
source_control.set_up_ignore_file()
File "/Users/mudassirali/.virtualenvs/rtp_dev/lib/python3.6/site-packages/ebcli/objects/sourcecontrol.py", line 294, in set_up_ignore_file
for line in f:
File "/Users/mudassirali/.virtualenvs/rtp_dev/lib/python3.6/encodings/ascii.py", line 26, in decode
return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 1287: ordinal not in range(128)
I jumped into the source code, specifically this bit
for line in f:
I found out this is the part which was throwing the error
with open('.gitignore', 'r') as f:
for line in f:
if line.strip() == git_ignore[0]:
return
Once I removed the .gitignore it worked like charm(and added it later without copy-paste)
It could be that your Beanstalk runs the Python environment without LC_ALL defined. Setting LC_ALL=en_US.UTF-8 in my Beanstalk environment properties resolved this issue for me.
Some background on these locale environment variables is available at: Explain the effects of export LANG, LC_CTYPE, LC_ALL
your aws credentials are at ~/.aws/config