I created a fairly large program written in python, and when I run it locally or on the server as a .py, it does not give me any problem.
However, if I use PyInstaller to create an executable, although it still works locally, it fails when I try to make a LAN connection, as if something in Windows or on the LAN blocks my connection.
I don't understand why in .py everything works perfectly while in .exe the program cannot connect to the SQL Server on the LAN. The program will have to connect to a SQL Server that will run on windows server 2012.
The only thing I haven't tried is trying to sign the program.
It would also be interesting to post the solution somewhere in order to help other people who have the same strange problem.
NOTE: I am using the pymssql library. I also tried using other libraries like pyodbc directly, always the same problem.
Related
I wrote a code for a Django server, and it works perfectly inside the shell of Pycharm.
Now, I want to run this server on a local computer constantly without being inside Pycharm's shell.
Also, because it's for a client of mine I don't want any open CMD windows or any other weird GUI- I want him to just access the website like any other website.
I've seen all kinds of solutions- running runserver with &, creating a virtual machine and running the server on it and etc.
I am familiar with Vmware and all, so if the proper solution is this It's OK. But I wonder- are there any other ways to run a server on a PC without installing any additional programs?
I need some advice. So I am a big fan of VS Code and I always use its embedded notebooks. I built a remote Jupyter Server on Oracle Cloud hoping I could connect from vscode. To create the server I based on this article, but migrating as advised by Jupyter to JupyterServer. I've also used miniconda isntead of venv.
The server seems to work correctly, I can access it from my browser and in my Windows Terminal SSH, open Jupyter Lab, create and run noteboooks in it, etc. The problem is when I try to use it with VS Code, when I try to specify de Jupyter Server for connections, it allows me to do it, it even prompts me that it is an insecure connection (I use self signed ssl certificate), and it does mark Jupyter Server: Remote BUT, when I try to select my interpreter, change my kernel, it only shows my local conda envs. if I run !hostname it shows me my local hostname, not my remotes, it isn't really connecting or using the remote Jupyter server to run the cells.
I've looked around and can`t find a way to make it work, I really want it to work with VS Code, any help?
This has no impact on the actual use of jupyter. Your confusion is actually a misunderstanding caused by the definition of names.
As stated in the official document, when you connect to a remote server, everything runs in the server ather than the local computer.
At present, there is an issue for changing the naming on GitHub, which you can read in detail.
I know how to run a Python script made locally on a remote server and have seen a lot of questions in that regard. But I am in a situation where I cannot install python packages on the remote server I am accessing. Specifically, I need to use pypostal, which requires libpostal to be installed and I cannot do so. Moreover, I need pyspark to play with Hive tables.
Therefore, I need the script to run locally, where I can manage my packages and everything executes fine, but certain commands need to access the server in order to grab data. For example, using pyspark to get Hive tables on the server into a local dataframe. Essentially, I need all the Python to be executed using my local distribution with my local packages but perform its actions on the remote server.
I have looked into things like paramiko. But as far as I can workout, is just like an SSH client, which would use the Python distro on the remote server and not locally. Though, perhaps I don't understand how to use it properly.
I am running python 3.6 on Ubuntu 18.04 using WSL. The packages I am using are pandas, numpy, pyspark, and postal (subsequently libpostal).
TLDR;
Is it possible to run a script locally, have parts of it execute remotely but using my local Python? Or if there are other possible solutions, I would be grateful.
I'm attempting to connect to an Access .mdb database with Python pyodbc. I connect to a local database, and this works fine. The database contains linked tables to a back end .mdb on a network drive. I receive this error when attempting to select from the linked table:
pyodbc.Error: ('HY024', "[HY024] [Microsoft] [ODBC Microsoft Access Driver] 'U:\OFFICE\GIS\accessdatabase.mdb' is not a valid path. Make sure that the path name is spelled correctly and that you are connected to the server on which the file resides. (-1023) (SQLExecDirectW)")
The path name is correct, and the linked tables work fine if I go into my local database and open them. The python program never mentions the network database or it's path at all, it only connects to the local database.
The python script works fine. I'm only getting the error when running the compiled .exe generated by Pyinstaller. Also, a coworker can compile on Windows 10 and his .exe works fine. But it has to compile on Windows 7 to produce an .exe that works on Windows 7.
Windows 7.
conn_str = (
r'DRIVER={Microsoft Access Driver (*.mdb)};'
r'Uid=Admin;Pwd=;'
r'DBQ=' + self.path
)
Any assistance or pointers would be greatly appreciated! Thanks
Not sure if this is an answer exactly, or more of a work around, but I got it to work by re-linking the remote database tables using '\server\name\path' style paths in the local database, instead of 'U:\path' style ones. Apparently the compiled program was trying to run as administrator for some reason, and in command window the mapped drives were unavailable when running as administrator. Figured I would share in case anyone else has a similar issue.
I have been interested in finding an alternative to the UI in SAS for quite some time now. We license SAS on our server instead of our desktops, so furthermore we have to launch a remote desktop application to execute code.
I was able to use a Telnet connection instead to remotely connect to the server, and batch execute SAS programs. Then I was interested in whether a python script could be made to connect remotely, and batch execute code, and this script could be executed in jEdit as a BeanShell script.
So far, I have Python code which successfully opens and closes the Telnet connection. It can do basic shell functions like call "dir". However, when I pass the exact same line that I use to execute SAS from command prompt on the remote server with a telnet connection in Python, nothing happens.
Is it possible the server is preventing me from executing code from a script? I use a "read_until" statement for the prompt before running any code.
Here's a few ideas...
The issue you are having above may be related to Local Security Policy settings in Windows (if it is running on a windows server). I'm far from an expert on that stuff but I remember older SAS/Intranet installations required some rumaging around in there to get them working.
As an alternative to the approach you are trying above you could also setup a SAS session on the server that listens for incoming socket requests as per this article:
http://analytics.ncsu.edu/sesug/2000/p-1003.pdf
And finally... Not sure if this helps or not by I remotely execute SAS jobs using PSEXEC. A description of how I set it all up can be found here:
http://www.runsubmit.com/questions/260/hide-sas-batch-jobs-winxp
Good luck
This paper outlines how you can use a Python script to connect to a Unix server using SSH, copy the SAS program written locally onto the server, batch submit it, and download the results back to your local machine, all using a BeanShell macro script for jEdit.