What to do to import a CSV file using a chromebook idle version python 3.7.3 shell - python-3.7

Keep getting this error message when I enter this code :
data = pd.read_csv('1.01. Simple linear regression.csv')
Traceback (most recent call last):
File "<pyshell#7>", line 1, in <module>
data = pd.read_csv('1.01. Simple linear regression.csv')
File "/usr/lib/python3/dist-packages/pandas/io/parsers.py", line 678, in parser_f
return _read(filepath_or_buffer, kwds)
File "/usr/lib/python3/dist-packages/pandas/io/parsers.py", line 440, in _read
parser = TextFileReader(filepath_or_buffer, **kwds)
File "/usr/lib/python3/dist-packages/pandas/io/parsers.py", line 787, in __init__
self._make_engine(self.engine)
File "/usr/lib/python3/dist-packages/pandas/io/parsers.py", line 1014, in _make_engine
self._engine = CParserWrapper(self.f, **self.options)
File "/usr/lib/python3/dist-packages/pandas/io/parsers.py", line 1708, in __init__
self._reader = parsers.TextReader(src, **kwds)
File "pandas/_libs/parsers.pyx", line 384, in pandas._libs.parsers.TextReader.__cinit__
File "pandas/_libs/parsers.pyx", line 695, in pandas._libs.parsers.TextReader._setup_parser_source
And the message :
FileNotFoundError: File b'1.01. Simple linear regression.csv' does not exist

(Best end a question with the question.) The current working directory for the program does not have a file by that name. Possible solutions:
Give a complete path to the file to read_csv.
Change the working directory in the program to the one that contain that file using os.chdir. See chdir doc.
Start python in that directory, with or without IDLE, from a command line.

Related

How to package locust file with pyinstaller

In virtual environment I installed locust.
I want to create distributable package so any user can run load tests.
I used pyinstaller.
The exe file is created but when I run it nothing happens.
from locust import HttpUser, TaskSet, task
import orjson as json
def create_post(self):
paramsDict = {}
paramsDict = json.loads('{ ...myjson.. }')
params = json.dumps(paramsDict) #for orjson
headers = {'content-type': 'application/json','Accept-Encoding':'gzip'}
response = self.client.post("/",data= params, headers=headers, name = "Post query")
print(f'response -> {response}')
class WebsiteUser(HttpUser):
tasks = [create_post]
I used locust as library as Axel pointed.
I build with pyinstaller and tests runs just web page is not displayed
I build with pyinstaller but web did not appear `response -> <Response [200]>
Traceback (most recent call last):
File "gevent\pywsgi.py", line 999, in handle_one_response
File "gevent\pywsgi.py", line 945, in run_application
File "flask\app.py", line 2464, in __call__
File "flask\app.py", line 2450, in wsgi_app
File "flask\app.py", line 1867, in handle_exception
File "flask\_compat.py", line 39, in reraise
File "flask\app.py", line 2447, in wsgi_app
File "flask\app.py", line 1952, in full_dispatch_request
File "flask\app.py", line 1821, in handle_user_exception
File "flask\_compat.py", line 39, in reraise
File "flask\app.py", line 1950, in full_dispatch_request
File "flask\app.py", line 1936, in dispatch_request
File "locust\web.py", line 419, in wrapper
File "locust\web.py", line 132, in index
File "flask\templating.py", line 138, in render_template
File "jinja2\environment.py", line 930, in get_or_select_template
File "jinja2\environment.py", line 883, in get_template
File "jinja2\environment.py", line 857, in _load_template
File "jinja2\loaders.py", line 115, in load
File "flask\templating.py", line 60, in get_source
File "flask\templating.py", line 89, in _get_source_fast
jinja2.exceptions.TemplateNotFound: index.html
2021-01-11T11:29:52Z {'REMOTE_ADDR': '127.0.0.1', 'REMOTE_PORT': '61083', 'HTTP_HOST': 'localhost:8089', (hidden keys: 31)} failed with TemplateNot
The template needs to be included in build.
Into spec file I added into data section as well as static with java scripts and css
datas=[('<path>\\Lib\\site-packages\\locust\\templates', 'locust\\templates'),('<path>\\Lib\\site-packages\\locust\\static', 'locust\\static')],
With Inno Setup I added also those to folders to be in same folder as executable.
And web page is displayed.
All depend on how are you expecting to get your test executed and what are your really packing. Locust have different ways of use. Assuming that you wanna pack your test file as an executable file you may need to include in your file a main entrypoint that use locust as a library
If you are packing the locust itself and the virtualenv including your test file you may need to specify how to run locust as a command and pass your test file as a command line argument

docker-compose up returns OSError: Can not read file in context: .../data/mmaps/5332641.mmtile

Followed the instructions from here: http://www.azerothcore.org/wiki/Install-with-Docker
I used the v8 data
When I run docker-compose up I get the following:
Building ac-worldserver
Traceback (most recent call last):
File "site-packages/docker/utils/build.py", line 97, in create_archive
File "tarfile.py", line 1972, in addfile
File "tarfile.py", line 250, in copyfileobj
File "tempfile.py", line 481, in func_wrapper
OSError: [Errno 28] No space left on device
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "bin/docker-compose", line 6, in <module>
File "compose/cli/main.py", line 72, in main
File "compose/cli/main.py", line 128, in perform_command
File "compose/cli/main.py", line 1077, in up
File "compose/cli/main.py", line 1073, in up
File "compose/project.py", line 548, in up
File "compose/service.py", line 367, in ensure_image_exists
File "compose/service.py", line 1106, in build
File "site-packages/docker/api/build.py", line 160, in build
File "site-packages/docker/utils/build.py", line 31, in tar
File "site-packages/docker/utils/build.py", line 100, in create_archive
OSError: Can not read file in context: /home/azerothcore/wotlk/azerothcore-wotlk/docker/worldserver/data/mmaps/5332641.mmtile
[21981] Failed to execute script docker-compose
It is likely disc space related, i had same error and there is an error above it that indicates the build ran out of disc space. Works after clearing space it uses over 10gb in my case.
I had the same error when I tried to mount a large file. The solution for me was to create a .dockerignore file containing the name of the directory where the large file was saved.

Running the Tensorflow2 upgrade Script triggers an encoding error

I am currently trying to upgrade a script to be compatible with tensorflow2 by using the jupyter notebook that is provided in https://www.tensorflow.org/guide/upgrade, so that I can run it in google colab, however when I run this cell (from an Anaconda environment in windows):
!tf_upgrade_v2 \
--infile D:/Multiclass.py\
--outfile /tmp/upgraded_Multiclass_CNN_V01_31012020Copy.py
I get an encoding error:
Traceback (most recent call last):
File "d:\programdata\miniconda3\envs\env_dlexp1\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "d:\programdata\miniconda3\envs\env_dlexp1\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "D:\ProgramData\Miniconda3\envs\Env_DLexp1\Scripts\tf_upgrade_v2.exe\__main__.py", line 7, in <module>
File "C:\Users\user\AppData\Roaming\Python\Python37\site-packages\tensorflow_core\tools\compatibility\tf_upgrade_v2_main.py", line 139, in main
args.input_file, output_file, upgrade)
File "C:\Users\user\AppData\Roaming\Python\Python37\site-packages\tensorflow_core\tools\compatibility\tf_upgrade_v2_main.py", line 40, in process_file
upgrader.process_file(in_filename, out_filename)
File "C:\Users\user\AppData\Roaming\Python\Python37\site-packages\tensorflow_core\tools\compatibility\ast_edits.py", line 900, in process_file
temp_file)
File "C:\Users\user\AppData\Roaming\Python\Python37\site-packages\tensorflow_core\tools\compatibility\ast_edits.py", line 958, in process_opened_file
lines = in_file.readlines()
File "d:\programdata\miniconda3\envs\env_dlexp1\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 14: character maps to <undefined>
I would normally change the encoding to utf-8 by doing this: open(path, mode, encoding='UTF8')
,but in this case I am clueless. I am not a programmer, so my proficiency is very limited. Please help me understand this error.
Try editing with open in line 918 of function process_file in ast_edits.py and specify encoding='utf-8', so that in the function process_opened_file the file can be read with utf-8.

Apache Beam Python wordcount example errors on Windows10

I am running Anaconda - conda virtual env with Python 2.7
I have followed Apache Beam Python SDK Quickstart
When I run -
'python -m apache_beam.examples.wordcount --input C:\Users\simon_6dagkya\OneDrive\ProgrammingCore\Apache Beam\examples\wordcount\kinglear.txt --output C:\Users\simon_6dagkya\OneDrive\ProgrammingCore\Apache Beam\examples\wordcount\output.txt'
I get following error:
INFO:root:Missing pipeline option (runner). Executing pipeline using the default runner: DirectRunner.
Traceback (most recent call last):
File "C:\Users\simon_6dagkya\Anaconda3\envs\apachebeam\lib\runpy.py", line 174, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "C:\Users\simon_6dagkya\Anaconda3\envs\apachebeam\lib\runpy.py", line 72, in _run_code
exec code in run_globals
File "C:\Users\simon_6dagkya\Anaconda3\envs\apachebeam\lib\site-packages\apache_beam\examples\wordcount.py", line 136, in <module>
run()
File "C:\Users\simon_6dagkya\Anaconda3\envs\apachebeam\lib\site-packages\apache_beam\examples\wordcount.py", line 90, in run
lines = p | 'read' >> ReadFromText(known_args.input)
File "C:\Users\simon_6dagkya\Anaconda3\envs\apachebeam\lib\site-packages\apache_beam\io\textio.py", line 524, in __init__
skip_header_lines=skip_header_lines)
File "C:\Users\simon_6dagkya\Anaconda3\envs\apachebeam\lib\site-packages\apache_beam\io\textio.py", line 119, in __init__
validate=validate)
File "C:\Users\simon_6dagkya\Anaconda3\envs\apachebeam\lib\site-packages\apache_beam\io\filebasedsource.py", line 121, in __init__
self._validate()
File "C:\Users\simon_6dagkya\Anaconda3\envs\apachebeam\lib\site-packages\apache_beam\options\value_provider.py", line 133, in _f
return fnc(self, *args, **kwargs)
File "C:\Users\simon_6dagkya\Anaconda3\envs\apachebeam\lib\site-packages\apache_beam\io\filebasedsource.py", line 181, in _validate
'No files found based on the file pattern %s' % pattern)
IOError: No files found based on the file pattern C:\Users\simon_6dagkya\OneDrive\ProgrammingCore\Apache
Any help most appreciated.
IOError: No files found based on the file pattern C:\Users\simon_6dagkya\OneDrive\ProgrammingCore\Apache
Your input string has a space in it. Add quotes.

Error when creating virtualenv folder

I am working through the book Test Driven Devlopement, and am currently having a problem when I try to create a virtualenv folder using:
virtualenv --python=python3 ../virtualenv
I keep on getting this output:
Traceback (most recent call last):
File "C:\Python33\lib\runpy.py", line 160, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "C:\Python33\lib\runpy.py", line 73, in _run_code
exec(code, run_globals)
File "C:\Python33\Scripts\virtualenv.exe\__main__.py", line 9, in <module>
File "C:\Python33\lib\site-packages\virtualenv.py", line 774, in main
interpreter = resolve_interpreter(options.python)
File "C:\Python33\lib\site-packages\virtualenv.py", line 1575, in resolve_interpreter
python_versions = get_installed_pythons()
File "C:\Python33\lib\site-packages\virtualenv.py", line 93, in get_installed_pythons
path = winreg.QueryValue(python_core, "%s\\InstallPath" % ver)
FileNotFoundError: [WinError 2] The system cannot find the file specified
You are on windows: ../virutalenv is for unix
On unix, you are telling virtualenv to create a virtualenv directory in the directory up one level (previous) also windows uses backslash instead of slash.
Try to find a tutorial that is windows oriented, or if you can get your hand on a unix/linux machine, or maybe install cygwin.