I am new to django. I have downloaded the django-admin-tools and extraced it then I put it in the location "C:\Python27". Then I entered into the location "C:\Python27\django-admin-tools-0.5.1" and type the command
python setup.py install
but the error is
'python' is not recognized as an internal or external command,
operable program or batch file.
What may be the solution ?
Add the python on the environment variable list by following steps listed below.
Steps:-
Go to Control Panel \System and Security\System
Click on Change Settings
Go to “Advance” tab
Click on Environment Variables
for details :- go here
Related
I'm using a GCP notebook instance (from Vertex AI to be precise), and I'm struggling to import a function in a Python script/module (in a particular folder) onto a notebook (in a different folder).
Therefore, is there any way I could set the root folder of my repo as the repo from which Python modules can be located? In Pycharm, I have the option of setting this root folder as the "Sources Root" and all imports work fine. However, I'm not sure how I can do this on JupyterLab of the notebook instance on GCP.
In the GCP Jupyter(IPython) Notebook, there is no option to set a “source root” like Pycharm IDE. If you want to set an own path to import Python modules/functions, follow the below solutions:
Example Project Structure:
/home/jupyter/ (Default root directory)
-src
-tutorial
-hello
- basic.py (function file)
-source
- test.ipynb
1. Temporary Solution
You can temporarily add the corresponding path of the function file to IPython using “sys.path.append”. For example, if “/home/jupyter/hello” was missing from your IPython path, you can append it as below:
import sys
sys.path.append('/home/jupyter/hello')
print(sys.path)
After executing the above code, you should be able to see “/home/jupyter/hello” added as a path in “sys.path”. For example, If you added a path through sys.path.append in “test.ipynb”, the added path only works in test.ipynb. It will not work on any other .ipynb. So, If you want to add a path common to all .ipynb, you should follow the permanent solution.
2. Permanent Solution
A permanent solution could be changing the IPython config options. So, open the terminal on the notebook and do the following steps:
Step 1: Go to file -> New -> Terminal and execute the following commands to create and locate an IPython config file. Of course, your IPython profile path will probably be different with the example below:
$ ipython profile create
$ ipython locate
/home/jupyter/.ipython
Step 2: To edit the config file, execute the following commands:
$ cd /home/jupyter/.ipython
$ nano profile_default/ipython_config.py
Step 3: Find the “#c.InteractiveShellApp.exec_lines“, remove the “#” to uncomment it. Add the following lines to add your own path to “sys.path” and save the changes you've made by pressing Ctrl + O and Enter. To exit nano, type Ctrl + X.
c.InteractiveShellApp.exec_lines = [ 'import sys; sys.path.append("/home/jupyter/hello")' ]
Step 4: Finally, close your current Jupyter notebook and go to the Notebooks page on VertexAI. Click the checkbox of the notebook instance which you configured. Stop the instance and start it again to update your configuration. Now, open the Jupyter notebook and test your code.
I am new to Jenkins, specially with using python script in Jenkins. The problem I am facing is as follow:
I am trying to run a python script from a python file in the post-build step of the Jenkins. I have added all the plugins required for that purpose to my understanding. i.e I have included Post-BuildScript plugin, python jenkins plugin etc.
Now when I build console output shows invalid script command caused the failure. I have attached the results below. can anybody help me with that please?
In post build step I am providing the full or absolute path to the python script file i.e
ExecutepythonScriptpath
Results
It may be useful to mention here I have also tried using just the path without writing python preceding the path, also tried with forward as well as backward slash in the path. without any success.
I have managed to resolve that issue. There are two parts of solution:
First one is if you want to run simple python script in post-build -->Add a post build step for Execute python Script (That will require you install plugin for post build ) . In that window created after adding post build step you can simply put any python command to run.
Second part of the solution is for, when user would like to run a list of commands from a python script file from the same post build step window in that case user has to make sure to put all the required python files which you want to execute into the Jenkins workspace->project directory(project for which we are running the Jenkins ) .
Moreover, for Python2.7 in order to execute that python script file user simply need to write script as
execfile(file.py)
One more thing to remember is insert python.exe path in the environment variables.
Hi Jenkins and AWS Guru's
I already look online for any possible solutions but not getting a solution for my problem. I just issued an "eb --version" on Jenkins execute shell under a test project but getting "eb: command not found" during the execution.
Wierd thing is if I issue the same command on the Jenkins box via CLI I'm getting a good response from it. Any suggestions for the fix please? thanks in advance
Your Jenkins setup has a different path than the user you logged in with.
There are two solutions:
Add the path to the executable in the PATH environment variable. Use where eb to find the correct path. Then in Jenkins, click on
Manage Jenkins -> Configure System, Global Properties. Check Environment Variables. Set Name to PATH. Set Value to $PATH:/path/to/eb. Then restart Jenkins.
Call the eb command with its fully qualified path.
EDIT: Added steps to update path in Jenkins.
this is now fixed, need to create a properties file that was basically a copy of /var/lib/jenkins/.bash_profile file which would have the correct paths and add that in Jenkins settings. Allowing it to get the required paths. After properties file is created you need to set it on Jenkins-Configure section, Place a check on Prepare jobs environment then set the full path of the properties file (/var/lib/jenkins/environment_variables.properties) on the Properties File Path and restart Jenkins
I'm trying to get the Neo4j on Heroku and Getting Started with Python on Heroku tutorials up and going. The Neo4j one works fine, but the Python one has problems.
For anyone else trying to follow this tutorial, I've recorded the
problems and my solutions to help you out as well.
This is all done on a Win7 x64 dev machine.
Q1) "virtualenv venv --distribute" - errors with:
'virtualenv' is not recognized as an internal or external command, operable program or batch file.
A1) The workaround is to fully qualify the path to:
"C:\Python27\Scripts\virtualenv venv --distribute"
Q2a) "foreman start" - errors with:
'foreman' is not recognized as an internal or external command, operable program or batch file.
A2) Looks like a path issue so I ran the line:
"set PATH=%PATH%;C:\Program Files (x86)\Heroku\ruby-1.9.2\bin\"
Q2b) "foreman start" now errors:
Bad file descriptor
{Ruby paths...}
A2b) Help?
So I can't run the app locally, but maybe still on the server, so moving on...
Q3) .gitignore - can't create this file on Windows.
A3) Clone another project and copy that file and edit.
Q4) "git push heroku master" - errors with:
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.
A4) Apparently need to create new SSH keys. Managing Your SSH Keys Note again fully quality the path such as below and select the new key to add to heroku.
"c:\Program Files (x86)\Git\bin\ssh-keygen.exe" -t rsa"
Q5) Try "git push heroku master" the same with the Neo4j test app "flask-py2neo" - errors during the compile. Is this example current?
A5) Remove distribute from requirements.txt.
Any ideas?
I know how to run commands with PyCharm (Tools -> Run manage.py Task), but I would like to debug them also, including my commands and third party app's commands.
You can debug a custom Django admin/management command in PyCharm by creating a custom Django server entry on the Run/Debug Configuration menu:
Click Edit Configurations....
Click the plus sign and choose Django server.
Fill in the Name as you please, clear the Host and Port fields,
check Custom run command and enter the name of your command to the
right of the checkbox.
Enter any extra command-line arguments into the separate field Additional options, not appended in the run command.
Click OK.
Now set a breakpoint, choose your new configuration from the Run/Debug Configuration menu and click the Debug button. Et voilà!
Since clearing Host and Port will not make the command run at all (PyCharm 5), the solution I found is to use a Python run configuration instead of a Django server. Fill Script with your manage.py script, other parameters in Script Parameters, and adjust your environment such as Working directory.
I am explaining using my following custom Django command:
python manage.py execute_algorithm -f input_data.json
Steps to configure Django Command:
Step: From Django toolbar go to:
Run > Edit Configurations
Click on the '+' icon at top left, to create new command >
select 'Django server' from the drop down.
Fill following details:
Name: any suitable name that you want to give to this config e.g. execute_algorithm_command
Host: Clear the field
Port: It's 8000 by default, clear it.
Custom Run Command: Check this box fist.
Provide your command name there. You can get that from apps/module/management/command/execute_algorithm.
e.g value: execute_algorithm
Additional options: Whatever is there, after you command name. value is: -f input_data.json