i have installed following packages to my windows machine -
python-numpy
python-matplotlib
python-pyside
but when i m running a command "python script.py" it says python is not an internal or external command
You need to add Python to your environmental variables.
More info under this link
http://docs.python.org/2/using/windows.html
Related
my goal is to follow this guide so that I can convert a Caffe model to a Tensorflow model. As my original OS is Windows 10 I am using the virtual Ubuntu 20.04 (using Oracle VirtualBox) with python 2.7 and anaconda virtual env. I am able to successfully install tensorflow for python 2.7, but when I run the command python -c 'import tensorflow', I get an error with text Illegal instruction (core dumped). I have tried to google to get more information but all I got was that it maybe has something to do with the architecture, I found out that my architecture (on the virtual ubuntu) is x86_64. That is all I have found out and now I turned to SO to ask what I should do to be able to run tensorflow in the before described environment, many thanks beforehand.
For those wondering, the pip or conda installation did not work in my case, so I followed the instructions on this guide for linux, python 2.7 using the pip installation method with a tensorflow version of 0.10, which for my purposes is good enough.
Exact steps in case the link does not work in the future:
$ conda create -n tensorflow python=2.7
$ conda activate tensorflow
Your prompt should change to this: (tensorflow)$
(tensorflow)$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.10.0-cp27-none-linux_x86_64.whl
(tensorflow)$ pip install --ignore-installed --upgrade $TF_BINARY_URL
This is, as outlined, for python 2.7, but the guide contains info for newer versions as well. To check whether tensorflow installed correctly you can run this command $ python -c 'import tensorflow as tf; print(tf.__version__)' which should output 0.10.0.
I typed django-admin startproject myproject in command pallet and it gave me this error message: 'django-admin' is not recognized as an internal or external command, operable program or batch file. I would realy appreciate some explination or tips. Thank you!
I will assume that you are using Linux. You have to follow some basic steps in order to make Django work.
First of all, verify if you have Python3 installed in your operating system:
python3 --version. It should return something like: 3.6.9.
Then, you have to install Django. I recommend using virtualenv for that. First of all, install venv and pip for Python:
sudo apt install python3-venv python3-pip.
Then, create virtual environment (so you don't break your "main" Python instance):
python3 -m venv venv.
Activate virtual environment:
source venv/bin/activate
Then, install Django in Virtual environment:
pip install django
If you followed all of the steps above, Django should create new project.
If you're using Windows, MacOS or ChromeBook - then verify, how to install Django there. In case of Windows I recommend WSL, so you can do everything in "linux way".
These methods may be helpful to you:
django-admin is not recognized as an internal or external command,operable program or batch file.
Troubleshooting “django-admin is not recognized”
django-admin' is not recognized as an internal or external command, operable program or batch file.
https://docs.djangoproject.com/en/3.0/howto/windows/
I try this command:
$ virtualenv .venv
$ sourse .venv/bin/activate
(.venv) $ pip3 install django
The last command installed the django3 on the whole system while the virtual machine was active and should only be installed on the virtual machine. why??
I tried django-admin stratproject mysite, but I received this error:
Command 'django-admin' not found, but can be installed with:
sudo apt install python-django-common
so, I try sudo apt install python-django-common. Then again try django-admin stratproject mysite and resived error: Cannot find installed version of python-django or python3-django.
how I can solve this problem??
Did you add a Python path. If you have, you can enter the Python terminal when you write Python. You can see the installed libraries by typing pip freeze.
The Django is not added in your python path , if you still want to run your code go to python directory and then run the django-admin command.
Go to the folder where your python is installed and open terminal there
after that run your command
django-admin startproject test
Try using pipinstall django instead of pip3 install django in virtualenv.
By running virtualenv .venv you have created local python environment with current default system version of python (i.e. on older distributions this might be python 2.7)
While activating virtual environment, it replaces some ENV variables to allow python to address this local environment, but not system one.
pip is one of them. pip inside virtualenv points to virtualenv's pip. Virtualenv might not redefine pip3 command - this is only needed system-wide, cause you may have many different versions of python in the system at the same time. And as far as virtualenv has only one version of python / packages inside - where is no need for it to redefine pip3.
Running django-admin startproject test inside virtualenv uses virtualenv's python packages, and if there is none, it may actually use system-wide packages, but it depends on the options virtualenv was created with (use system pacakges), PATH variables etc.
Also, try not to install or rely on system-wide packages - use virtuelnv.
Using virtualenv is good, and there is a lot of helpers to ease - pipenv, virtualenwrapper etc
Just run this in the command line.
apt-get install python3-django
Hope this will solve your problem.
With node.js, I can typically do something like npm install example and then my code can import and use that module like var m = require('example'); m.dostuff();. The module and any dependencies are saved locally in a directory and that code and my code is portable.
Some modules run as command line programs when you install like npm install -g example and run from the command line ./example dostuff. These modules get installed globally and are part of the PATH.
I am trying to install mkdocs locally. However running pip install mkdocs seems to install it globally which is not desirable.
Is it possible to install locally like my first example and invoke from another python program.
This will work.
pip install --target=/target/dir/name mkdocs
But you need to add /target/dir/name to PYTHONPATH env variable.
You could use virtualenv to avoid system wide installation. It'll create dedicated virtual environment to run your python programs in.
# install virtualenv
$ [sudo] pip install virtualenv
# create virtual environment 'docs_env'
$ virtualenv docs_env
# activate virtual environment (it adds docs_env/bin as first PATH entry)
$ source ./docs_env/bin/activate
# install mkdocs in virtual environment
(docs_env)$ pip install mkdocs
# you can run python scripts anywhere, as long as 'docs_env' is activated
(docs_env)$ python do_something_with_mkdocs.py
# if you need to leave 'docs_env' (it undoes PATH change)
(docs_env)$ deactivate
More infos: http://virtualenv.readthedocs.org/en/latest/index.html
I installed Python 2.7.9 from (https://www.python.org/downloads/windows/), and then Cygwin 2.8.59. But I had problems when installing numpy.
pip install numpy
error: Unable to find vcvarsall.bat
So I uninstalled python using set-x86.exe (Cygwin installer). Now my commands python and pip are these:
$ which python
/cygdrive/c/Python27/python
$ which pip
/cygdrive/c/Python27/Scripts/pip
I could installed numpy using pip, and execute files by "python test.py". I, however, cannot use interactive console. If I type
$python
the console freezes and I cannot do anything other than Ctrl+C.
How should I do to use the command, "python"?
Try
cygstart /cygdrive/c/Python27/python.exe
According to this question: Using Windows Python from Cygwin
cygwin is just going to hang because windows doesn't think that the cygwin command 'Python' means interactive console, and will not flush the buffer as if it were an interactive console.