Discuss Scratch
- Discussion Forums
- » Advanced Topics
- » PyHelp - The official Scratch Python help forum | Ask, help, discuss, & more! | +800 posts! |
- LoIdesMio
- Scratcher
100+ posts
PyHelp - The official Scratch Python help forum | Ask, help, discuss, & more! | +800 posts! |
lmao its messier that ma code
Anyways so I have been working on a v3.0 of my image loader which sends images to scratch its prob the fastest on Scratch ;-; but like if I implement B64 each char size will go from 6 char to 4 char. Btw by image loader you might have seen my Thumbnail Project where it gives a projects image in a Scratch project. But well idk how to change hex to b64 in a colour things everytime that I've tried to change each colour to a b64 it hasn't worked but then changing it back into hex in Scratch any ideas how? (I mean convert a hex colour to B64 and then back into hex in Scratch)
Btw a person has done this it just was super laggy ;-;
I make cloud Games! Using Scratchattach by @TimMcCool!
- -OwlOS-
- Scratcher
22 posts
PyHelp - The official Scratch Python help forum | Ask, help, discuss, & more! | +800 posts! |
Could someone explain to me how to read write, and delete text from .txt files using python3?
When I shut down my forum topic for OwlOS1, my automatic evil kumquat alarm broke, so they got in to our servers and ate my signature.
- LoIdesMio
- Scratcher
100+ posts
PyHelp - The official Scratch Python help forum | Ask, help, discuss, & more! | +800 posts! |
If you read these it should help its simple Could someone explain to me how to read write, and delete text from .txt files using python3?https://www.w3schools.com/python/python_file_handling.asp
I make cloud Games! Using Scratchattach by @TimMcCool!
- wvzack
- Scratcher
500+ posts
PyHelp - The official Scratch Python help forum | Ask, help, discuss, & more! | +800 posts! |
My code:
Is making:
Seems like i am making to many different requests (this is done in a virtual environment).
#import import requests import json import pandas as pd #square shape lon_min=-123.063498 lat_min=-49.082514 lon_max=-123.295758 lat_max=49.308148 #requests user_name='wvzack' password='########' url_data='https://' + user_name + ':' + password + '@opensky-network.org/api/states/all?'+'lamin=' + str(lat_min) +'&lomin=' + str(lon_min) + '&lamax=' + str(lat_max) + '&lomax=' + str(lon_max) response=requests.get(url_data).json() #pandas col_name=['icao24','callsign','origin_country','time_position','last_contact','long','lat','baro_altitude','on_ground','velocity', 'true_track','vertical_rate','sensors','geo_altitude','squawk','spi','position_source'] flight_df=pd.DataFrame(response['states']) flight_df=flight_df.loc[:,0:16] flight_df.columns = col_name flight_df=flight_df.fillna('No Info') flight_df.head() print(flight_df)
Is making:
Traceback (most recent call last):
File "c:\Users\###\pytho me-is.py", line 25, in <module>
flight_df.columns = 17
^^^^^^^^^^^^^^^^^
File "C:\Users\###\venv\Lib\site-packages\pandas\core\generic.py", line 6002, in __setattr__
return object.__setattr__(self, name, value)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "pandas\_libs\properties.pyx", line 69, in pandas._libs.properties.AxisProperty.__set__
File "C:\Users\###venv\Lib\site-packages\pandas\core\generic.py", line 729, in _set_axis
labels = ensure_index(labels)
^^^^^^^^^^^^^^^^^^^^
File "C:\Users\###\venv\Lib\site-packages\pandas\core\indexes\base.py", line 7125, in ensure_index
return Index(index_like, copy=copy)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\###\venv\Lib\site-packages\pandas\core\indexes\base.py", line 516, in __new__
raise cls._raise_scalar_data_error(data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\###\venv\Lib\site-packages\pandas\core\indexes\base.py", line 5065, in _raise_scalar_data_error
raise TypeError(
TypeError: Index(...) must be called with a collection of some kind, 17 was passed
Seems like i am making to many different requests (this is done in a virtual environment).
Last edited by wvzack (June 21, 2023 12:45:54)
- undeterminstic
- Scratcher
1000+ posts
PyHelp - The official Scratch Python help forum | Ask, help, discuss, & more! | +800 posts! |
col_names need to be a collection
yes
- wvzack
- Scratcher
500+ posts
PyHelp - The official Scratch Python help forum | Ask, help, discuss, & more! | +800 posts! |
Ummmm, i have never heard of that, How do i fix this? col_names need to be a collection
- Maximouse
- Scratcher
1000+ posts
PyHelp - The official Scratch Python help forum | Ask, help, discuss, & more! | +800 posts! |
Is the error message really from this code? It says the line at which the error happened is My code: flight_df.columns = 17, but in the code you posted, flight_df.columns is set to col_name.
[code]
Is making:
[error]
Seems like i am making to many different requests (this is done in a virtual environment).
It's already a collection, so that can't be the problem. A collection is a list, dict, tuple or any other similar object.Ummmm, i have never heard of that, How do i fix this? col_names need to be a collection
- wvzack
- Scratcher
500+ posts
PyHelp - The official Scratch Python help forum | Ask, help, discuss, & more! | +800 posts! |
As far as i know its this code I will try running it again.Is the error message really from this code? It says the line at which the error happened is My code: flight_df.columns = 17, but in the code you posted, flight_df.columns is set to col_name.
[code]
Is making:
[error]
Seems like i am making to many different requests (this is done in a virtual environment).It's already a collection, so that can't be the problem. A collection is a list, dict, tuple or any other similar object.Ummmm, i have never heard of that, How do i fix this? col_names need to be a collection
Edit: Is pandas known for this?
Edit 2: I got this:
Traceback (most recent call last): File "C:\Users\#####\venv\Lib\site-packages\urllib3\connection.py", line 200, in _new_conn sock = connection.create_connection( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\#####\venv\Lib\site-packages\urllib3\util\connection.py", line 60, in create_connection for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\#####\AppData\Local\Programs\Python\Python311\Lib\socket.py", line 962, in getaddrinfo for res in _socket.getaddrinfo(host, port, family, type, proto, flags): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ socket.gaierror: [Errno 11001] getaddrinfo failed The above exception was the direct cause of the following exception: Traceback (most recent call last): File "C:\Users\#####\venv\Lib\site-packages\urllib3\connectionpool.py", line 790, in urlopen response = self._make_request( ^^^^^^^^^^^^^^^^^^^ File "C:\Users\#####\venv\Lib\site-packages\urllib3\connectionpool.py", line 491, in _make_request raise new_e File "C:\Users\#####\venv\Lib\site-packages\urllib3\connectionpool.py", line 467, in _make_request self._validate_conn(conn) File "C:\Users\#####\venv\Lib\site-packages\urllib3\connectionpool.py", line 1092, in _validate_conn conn.connect() File "C:\Users\#####\venv\Lib\site-packages\urllib3\connection.py", line 604, in connect self.sock = sock = self._new_conn() ^^^^^^^^^^^^^^^^ File "C:\Users\#####\venv\Lib\site-packages\urllib3\connection.py", line 207, in _new_conn raise NameResolutionError(self.host, self, e) from e urllib3.exceptions.NameResolutionError: <urllib3.connection.HTTPSConnection object at 0x000002A51AD03450>: Failed to resolve 'wvzack' ([Errno 11001] getaddrinfo failed) The above exception was the direct cause of the following exception: Traceback (most recent call last): File "C:\Users\#####\venv\Lib\site-packages\requests\adapters.py", line 486, in send resp = conn.urlopen( ^^^^^^^^^^^^^ File "C:\Users\#####\venv\Lib\site-packages\urllib3\connectionpool.py", line 844, in urlopen retries = retries.increment( ^^^^^^^^^^^^^^^^^^ File "C:\Users\#####\venv\Lib\site-packages\urllib3\util\retry.py", line 515, in increment raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='wvzack', port=443): Max retries exceeded with url: / (Caused by NameResolutionError("<urllib3.connection.HTTPSConnection object at 0x000002A51AD03450>: Failed to resolve 'wvzack' ([Errno 11001] getaddrinfo failed)")) During handling of the above exception, another exception occurred: Traceback (most recent call last): File "c:\Users\#####\pytho me-is.py", line 17, in <module> response=requests.get(url_data).json() ^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users/#####\venv\Lib\site-packages\requests\api.py", line 73, in get return request("get", url, params=params, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\#####\venv\Lib\site-packages\requests\api.py", line 59, in request return session.request(method=method, url=url, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\#####\venv\Lib\site-packages\requests\sessions.py", line 589, in request resp = self.send(prep, **send_kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\#####\venv\Lib\site-packages\requests\sessions.py", line 703, in send r = adapter.send(request, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\#####\venv\Lib\site-packages\requests\adapters.py", line 519, in send raise ConnectionError(e, request=request) requests.exceptions.ConnectionError: HTTPSConnectionPool(host='wvzack', port=443): Max retries exceeded with url: / (Caused by NameResolutionError("<urllib3.connection.HTTPSConnection object at 0x000002A51AD03450>: Failed to resolve 'wvzack' ([Errno 11001] getaddrinfo failed)"))
This error makes a lot more sense.
Last edited by wvzack (June 21, 2023 12:52:55)
- Maximouse
- Scratcher
1000+ posts
PyHelp - The official Scratch Python help forum | Ask, help, discuss, & more! | +800 posts! |
This error is the important one. Apparently requests thinks “wvzack” is a domain name and tries to resolve it – most likely because the password contains special characters that aren't valid in a URL. I don't know how this particular API works, but the right way to send your credentials is probably like this:Traceback (most recent call last): File "C:\Users\#####\venv\Lib\site-packages\urllib3\connectionpool.py", line 790, in urlopen response = self._make_request( ^^^^^^^^^^^^^^^^^^^ File "C:\Users\#####\venv\Lib\site-packages\urllib3\connectionpool.py", line 491, in _make_request raise new_e File "C:\Users\#####\venv\Lib\site-packages\urllib3\connectionpool.py", line 467, in _make_request self._validate_conn(conn) File "C:\Users\#####\venv\Lib\site-packages\urllib3\connectionpool.py", line 1092, in _validate_conn conn.connect() File "C:\Users\#####\venv\Lib\site-packages\urllib3\connection.py", line 604, in connect self.sock = sock = self._new_conn() ^^^^^^^^^^^^^^^^ File "C:\Users\#####\venv\Lib\site-packages\urllib3\connection.py", line 207, in _new_conn raise NameResolutionError(self.host, self, e) from e urllib3.exceptions.NameResolutionError: <urllib3.connection.HTTPSConnection object at 0x000002A51AD03450>: Failed to resolve 'wvzack' ([Errno 11001] getaddrinfo failed)
url_data='https://opensky-network.org/api/states/all?'+'lamin=' + str(lat_min) +'&lomin=' + str(lon_min) + '&lamax=' + str(lat_max) + '&lomax=' + str(lon_max) response=requests.get(url_data, auth=(user_name, password)).json()
(Off-topic: you can use [code=py3tb] to post a Python traceback with correct syntax highlighting.)
Last edited by Maximouse (June 21, 2023 13:57:55)
- wvzack
- Scratcher
500+ posts
PyHelp - The official Scratch Python help forum | Ask, help, discuss, & more! | +800 posts! |
Okay and still trying to figure out how to make the request but the weird thing is that the passcode only had lowercase letters.This error is the important one. Apparently requests thinks “wvzack” is a domain name and tries to resolve it – most likely because the password contains special characters that aren't valid in a URL. I don't know how this particular API works, but the right way to send your credentials is probably like this: -snip-url_data='https://opensky-network.org/api/states/all?'+'lamin=' + str(lat_min) +'&lomin=' + str(lon_min) + '&lamax=' + str(lat_max) + '&lomax=' + str(lon_max) response=requests.get(url_data, auth=(user_name, password)).json()
(Off-topic: you can use [code=py3tb] to post a Python traceback with correct syntax highlighting.)
Edit: I still get the “Expected axis has 0 elements, new values have 17 elements” error.
Last edited by wvzack (June 21, 2023 15:22:50)
- LoIdesMio
- Scratcher
100+ posts
PyHelp - The official Scratch Python help forum | Ask, help, discuss, & more! | +800 posts! |
Hey! So I was just curious I just discovered Github Codespaces and was running if it was possible to keep my project running 24/7 like how you use UpTimeRobot to keep your Replit project running is it possible in Github?
I make cloud Games! Using Scratchattach by @TimMcCool!
- Air_heads
- Scratcher
92 posts
PyHelp - The official Scratch Python help forum | Ask, help, discuss, & more! | +800 posts! |
Hey I was wondering if I could join, as I have a lot of experience with python. I can work with pretty much all of the standard editors (replit, vs code, pychram, codesandbox)
- ScratchTheCoder12345
- Scratcher
500+ posts
PyHelp - The official Scratch Python help forum | Ask, help, discuss, & more! | +800 posts! |
Yep! I remember you Air heads I thought I accepted your request a while ago… Hey I was wondering if I could join, as I have a lot of experience with python. I can work with pretty much all of the standard editors (replit, vs code, pychram, codesandbox)
- wvzack
- Scratcher
500+ posts
PyHelp - The official Scratch Python help forum | Ask, help, discuss, & more! | +800 posts! |
Making a program and this happened?
& : File C:\Users\####\venv\Scripts\Activate.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170. At line:1 char:3 + & C:/Users/######/venv/Scripts/Activate.ps1 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : SecurityError: (:) [], PSSecurityException + FullyQualifiedErrorId : UnauthorizedAccess
- WojtekGame
- Scratcher
1000+ posts
PyHelp - The official Scratch Python help forum | Ask, help, discuss, & more! | +800 posts! |
don't use powershell or google how to turn off (this is common for nodemon) Making a program and this happened?& : File C:\Users\####\venv\Scripts\Activate.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170. At line:1 char:3 + & C:/Users/######/venv/Scripts/Activate.ps1 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : SecurityError: (:) [], PSSecurityException + FullyQualifiedErrorId : UnauthorizedAccess
forgot to update sig, i own minecraft months ago lol
maybe even a year at this point
- rishi272011
- Scratcher
99 posts
PyHelp - The official Scratch Python help forum | Ask, help, discuss, & more! | +800 posts! |
Are you using a school computer or any computer in which powershell scripts are disabled? Making a program and this happened?& : File C:\Users\####\venv\Scripts\Activate.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170. At line:1 char:3 + & C:/Users/######/venv/Scripts/Activate.ps1 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : SecurityError: (:) [], PSSecurityException + FullyQualifiedErrorId : UnauthorizedAccess
Last edited by rishi272011 (June 23, 2023 16:18:23)
- wvzack
- Scratcher
500+ posts
PyHelp - The official Scratch Python help forum | Ask, help, discuss, & more! | +800 posts! |
Not sure what you mean i am not using powershell (I dont think) or google.don't use powershell or google how to turn off (this is common for nodemon) Making a program and this happened?& : File C:\Users\####\venv\Scripts\Activate.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170. At line:1 char:3 + & C:/Users/######/venv/Scripts/Activate.ps1 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : SecurityError: (:) [], PSSecurityException + FullyQualifiedErrorId : UnauthorizedAccess
No its my pc.Are you using a school computer or any computer in which powershell scripts are disabled? Making a program and this happened?& : File C:\Users\####\venv\Scripts\Activate.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170. At line:1 char:3 + & C:/Users/######/venv/Scripts/Activate.ps1 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : SecurityError: (:) [], PSSecurityException + FullyQualifiedErrorId : UnauthorizedAccess
- rishi272011
- Scratcher
99 posts
PyHelp - The official Scratch Python help forum | Ask, help, discuss, & more! | +800 posts! |
How did this happen? Making a program and this happened?& : File C:\Users\####\venv\Scripts\Activate.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170. At line:1 char:3 + & C:/Users/######/venv/Scripts/Activate.ps1 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : SecurityError: (:) [], PSSecurityException + FullyQualifiedErrorId : UnauthorizedAccess
Did you use vscode's virtual environment option or are you following a tutorial on how to create a venv?
Try running:
activate.bat
- wvzack
- Scratcher
500+ posts
PyHelp - The official Scratch Python help forum | Ask, help, discuss, & more! | +800 posts! |
oh i did not know that vscode has a virtual environment and yes i followed a tutorial.How did this happen? Making a program and this happened?& : File C:\Users\####\venv\Scripts\Activate.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170. At line:1 char:3 + & C:/Users/######/venv/Scripts/Activate.ps1 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : SecurityError: (:) [], PSSecurityException + FullyQualifiedErrorId : UnauthorizedAccess
Did you use vscode's virtual environment option or are you following a tutorial on how to create a venv?
Try running:in the command line or terminal.activate.bat
- MonkeyBean2
- Scratcher
100+ posts
PyHelp - The official Scratch Python help forum | Ask, help, discuss, & more! | +800 posts! |
Don't use windows. Making a program and this happened?& : File C:\Users\####\venv\Scripts\Activate.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170. At line:1 char:3 + & C:/Users/######/venv/Scripts/Activate.ps1 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : SecurityError: (:) [], PSSecurityException + FullyQualifiedErrorId : UnauthorizedAccess