How to update python in sql server? - python

I have a Python project that uses the keras Library.
Now I want to transfer this to sqlserver ml service, but the Python sqlserver version is 3.7.1.
Is there a way to update the built-in version of Python in sqlserver?
EXECUTE sp_execute_external_script
#language = N'Python'
, #script = N'
import sys
print(sys.version)'
result:
STDOUT message(s) from external script: 3.7.1 (default, Dec 10 2018, 22:54:23) [MSC v.1915 64bit (AMD64)]

Related

How do I view the contents of a pandas dataframe column untruncated

When trying to display a dataframe with a column called 'cmdline', using Jupyter Notebook, the value is being truncated and after a google search I found the following solution:
pd.set_option('display.max_rows', None)
pd.set_option('display.max_columns', None)
pd.set_option('display.width', None)
pd.set_option('display.max_colwidth', -1)
df1.head(n = 15)
but none of this helped. The 'cmdline' column is still too narrow and not showing the full text in the column. Does anyone know of a solution. The above is all I could find using a Google search.
edit:
the dataframe was generated by
import sqlite3
conn = sqlite3.connect("ram-usage.db")
df1 = pd.read_sql("select datetime, cmdline, sum(resident) as resident, sum(shared) as shared from processdata where datetime > '2019-09-25' and datetime < '2019-09-26' group by datetime, cmdline ;", conn)
The version of software components I copy and pasted below:
Server Information:
You are using Jupyter notebook.
The version of the notebook server is: 5.7.0
The server is running on this version of Python:
Python 3.6.6 | packaged by conda-forge | (default, Oct 12 2018, 14:08:43)
[GCC 4.8.2 20140120 (Red Hat 4.8.2-15)]
Current Kernel Information:
Python 3.6.6 | packaged by conda-forge | (default, Oct 12 2018, 14:08:43)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.0.1 -- An enhanced Interactive Python. Type '?' for help.
The notebook itself is run from Docker
docker run --group-add=root --rm -p 8888:8888 -e "PASSWORD=xxxxxxxx" -e "USE_HTTP=1" -v "$PWD":/home/jovyan jupyter/scipy-notebook
if you want to look at the database file itself it can be downloaded from http://files.kiwiheretic.xyz/ram-usage.tar.gz or http://files.kiwiheretic.xyz/ram-usage.db
I will suggest you run your code in a different IDE (like Spyder). Then you can view the entire dataframe by simply clicking on the object in the variable explorer.

ArgumentParser is not working well if we start with assigned app on the commandline

I use argparse many years and start the scripts with the default app linked to .py.
Recently it likes that argparse do nothing. If I starts with
py test.py -d
or
python script.py -d
is everthing normal.
In past, there was no problem. I change my startup scripts with prolog: "python".
import sys
from argparse import ArgumentParser
if __name__ == "__main__":
parser = ArgumentParser()
parser.add_argument('-d', '--debug', help='debug mode', action='store_true')
args = parser.parse_args()
print(sys.version)
print(args)
print(args.debug)
What we has a result:
c:\Work>test.py -d
3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 22:22:05) [MSC v.1916 64 bit (AMD64)]
Namespace(debug=False)
False
c:\Work>python test.py -d
3.7.1 (default, Dec 10 2018, 22:54:23) [MSC v.1915 64 bit (AMD64)]
Namespace(debug=True)
True
The association in Windows 10 - Settings (Choose default apps by file type) was setting to "Python".
I change is no to "Python launch" and everthing is now working well.

Pycharm Couldn't connect to console process exit code -1 remote interpreter

I'm trying to connect to a remote python interpreter but I'm getting the following error in the Python Console:
ssh://ubuntu#131.175.21.168:22/usr/bin/python3.6 -u /home/ubuntu/.pycharm_helpers/pydev/pydevconsole.py 0 0
Couldn't connect to console process.
Process finished with exit code -1
I'm using the following:
Pycharm version: Pycharm Professional 2017.3.4.
Project interpreter: Remote Python 3.6.5 (ssh connection to a remote virtual ubuntu 16.04 server built thru OpenStack).
Deployment: SFTP, auth type: Key pair with private key file.
The SFTP connection works fine, synchronization of the code to the remote server also works fine. But I can't seem to run any code in the Python Console.
Any ideas on how to solve this?
Thanks in advance for the help!
When I try to connect directly to port 22, I get an error like below.
ssh://keiichi.kuroyanagi#mygcp:22/home/keiichi.kuroyanagi/.pyenv/shims/python -u /home/keiichi.kuroyanagi/.pycharm_helpers/pydev/pydevconsole.py 0 0
Couldn't connect to console process.
Process finished with exit code -1
I now connect to remote console by configuring portforwarding in RoyalTSX as below.
The console is as follows.
ssh://keiichi.kuroyanagi#localhost:10022/home/keiichi.kuroyanagi/.pyenv/shims/python -u /home/keiichi.kuroyanagi/.pycharm_helpers/pydev/pydevconsole.py 0 0
import sys; print('Python %s on %s' % (sys.version, sys.platform))
sys.path.extend(['/home/keiichi.kuroyanagi/tmp/pycharm_project_444', '/home/keiichi.kuroyanagi/tmp/pycharm_project_444'])
Python 3.6.7 |Anaconda, Inc.| (default, Oct 23 2018, 19:16:44)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.1.1 -- An enhanced Interactive Python. Type '?' for help.
PyDev console: using IPython 7.1.1
Python 3.6.7 |Anaconda, Inc.| (default, Oct 23 2018, 19:16:44)
[GCC 7.3.0] on linux
In[2]:
The following link may also be helpful.
Can't connect to remote interpreter python console : PY-18029
https://youtrack.jetbrains.com/issue/PY-18029
My pycharm version is as follows.
PyCharm 2018.2.4 (Professional Edition)
Build #PY-182.4505.26, built on September 19, 2018
Licensed to DeNA Co.,Ltd. / Keiichi Kuroyanagi
You have a perpetual fallback license for this version
Subscription is active until October 24, 2019
JRE: 1.8.0_152-release-1248-b8 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
macOS 10.13.6

Ansible EC2 Region eu-central-1does not seem to be available for aws module boto.ec2

Im trying to do a simple Ansible script to attach a volume in EC2
- ec2_vol:
instance: XXXXXX
volume_size: 5
device_name: sdd
When running I get the following error
msg": "Region eu-central-1 does not seem to be available for aws
module boto.ec2. If the region definitely exists, you may need to
upgrade boto or extend with endpoints_path"
When I check that eu-central-1 is accesible via python boto... it is there:
$ python
Python 2.7.12 (default, Nov 19 2016, 06:48:10)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import boto.ec2
>>> boto.ec2.regions()
[RegionInfo:us-west-1, RegionInfo:us-east-1, RegionInfo:ap-northeast-1, RegionInfo:ap-southeast-2, RegionInfo:sa-east-1, RegionInfo:ap-northeast-2, RegionInfo:us-east-2, RegionInfo:ap-southeast-1, RegionInfo:ca-central-1, RegionInfo:cn-north-1, RegionInfo:us-west-2, RegionInfo:us-gov-west-1, RegionInfo:ap-south-1, RegionInfo:eu-central-1, RegionInfo:eu-west-1, RegionInfo:eu-west-2]
Here are the versions of my tools
ansible 2.3.2.0
aws-cli 1.11.151
Python 2.7.12
Linux 4.4.0-93-generic
botocore 1.7.9
boto 2.48.0
pip 9.0.1
I already check most of the things I can think of and even reproduce it on another virtual machine with vagrant and it gives me the same error..what else can I check?
Do you run this with connection: local? – Konstantin Suvorov 6 hours
ago
Answer from the comments:
Do you run this with connection: local?
Cloud modules like ec2_vol are (usually) supposed to be executed from localhost (where all required libraries and credentials are stored).

Unknown screen output of manually installed Python 2.7

I installed Python 2.7 today using:
./configure --prefix=/home/zhanwu/local --enable-shared --enable-profiling --with-pydebug
make install
Then I keep getting something like "[37745 refs]" on screen after each function call:
[zhanwu#cluster ~]$ ~/local/bin/python
Python 2.7.1 (r271:86832, Jun 16 2011, 17:45:05)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-44)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
[37745 refs]
>>> print 'test'
test
[37745 refs]
>>> sys.exit()
[18048 refs]
[zhanwu#cluster ~]$
What does those numbers mean? Anything wrong here and can I get rid of them?
uname -a result:
[zhanwu#cluster ~]$ uname -a
Linux cluster.xxx.xxx.xxx 2.6.18-128.1.14.el5 #1 SMP Wed Jun 17 06:38:05 EDT 2009 x86_64 x86_64 x86_64 GNU/Linux
You get these because you configured the build with --with-pydebug. They denote the number of references Python is currently keeping track of. To get rid of them, configure without --with-pydebug.

Categories

Resources