converting python script to another version - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: converting python script to another version (/thread-8877.html) |
converting python script to another version - gptura - Mar-11-2018 Hi everyone, I saw a project using raspberry pi using python ver 3.4 and the flask framework. My raspberry pi has the Python 2.7, 3.5 and 3.6 Python versions. I have tried running the script but I always getting a bunch of errors. I have tried so many solutions that I have seen in the web and have ask for help in several forums but no luck . I have given up on addressing the error but if you want to know what I am facing, here is the link https://raspberrypi.stackexchange.com/questions/80181/no-module-named-psutil?noredirect=1#comment126909_80181 What I am thinking is maybe I can convert the scripts (just two files) to the latest version of Python? rather than fixing my Python environment which I have been doing for the last 24 hours. . I am new to Python and I want to learn the language plus the flask framework. May I know some tips before I try converting these files to the latest version and is this possible? Thanks in advance! RE: converting python script to another version - snippsat - Mar-11-2018 When you do sudo python web_plantes.py .python is most likely pointing to python 2,try python3 .I use pyenv then both python and pip is pointing to 3.6.4. But can easily go back default distro setting. mint@mint ~ $ python -V Python 3.6.4 # Go back to default distro setting mint@mint ~ $ pyenv local system mint@mint ~ $ python -V Python 2.7.12 mint@mint ~ $ python3 -V Python 3.5.2 mint@mint ~ $ pip3 -V pip 9.0.1 from /usr/local/lib/python3.5/dist-packages (python 3.5) # install to python 3.5 mint@mint ~ $ pip3 install --user psutil Collecting psutil Using cached psutil-5.4.3.tar.gz Installing collected packages: psutil Running setup.py install for psutil ... done Successfully installed psutil-5.4.3 # Test that module work in 3.5 mint@mint ~ $ python3 Python 3.5.2 (default, Nov 17 2016, 17:05:23) [GCC 5.4.0 20160609] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import psutil >>> psutil.__version__ '5.4.3' >>>So you see on the default distro setting i most use python3 .Tutorial Linux Python 3 environment RE: converting python script to another version - gptura - Mar-11-2018 @snippsat, thank you so for the help the psutil error I was getting is gone but this time it is throwing this error. See below. Thanks again. RE: converting python script to another version - snippsat - Mar-11-2018 Do not post picture when you can use code tag. You should also have posted a link to script that you try to run. Raspberry Pi Automated Plant Watering with Website There is another process already listening on that port,try and other port.app.run(host='0.0.0.0', port=8000, debug=True) # Or,now run on this address in browser http://localhost:5000/ app.run(debug=True) RE: converting python script to another version - gptura - Mar-11-2018 Thank you for the help, will post the results later. :-) RE: converting python script to another version - gptura - Mar-13-2018 Hi guys, @snippsat, Thank you for the last solution that you gave it worked now! Your the man! |