How to setup python to use at Terminal in PyCharm - python

I am running PyCharm on a server without administrative acess.
The server has Python 2.7 installed.
I am using Anaconda3 Python 3.5.3 when running programs and in the Console.
However, I cannot find where to set the Terminal of PyCharm to the same Python (Anaconda3/Python 3.5.3)
It keeps using the 2.7 and I cannot delete it from the server.
Thanks.
Appreciate the help.

You have to set up the path to the correct python binaries, when you add the remote interpreter in PyCharm:
Write there the path to your anaconda installation. So in your case the Python interpreter path is something like:
/your_install_path/anaconda/bin/python3

Related

How does the Windows Python Launcher (py.exe) find the python executable(s)?

I'm trying to use the Windows Python Launcher (py.exe) for the first time. I run python in a command shell but the launcher, running in the same shell, can't find any version of python.exe to run:
where python
C:\Python38\python.exe
py --list
Installed Pythons found by py Launcher for Windows
No Installed Pythons Found!
Obviously there is something missing in my configuration but I'm at a loss as to what. I've been digging into the registery and have located keys in:
HKEY_LOCAL_MACHINE/SOFTWARE/Wow6432Node/Python/PyLauncher
HKEY_LOCAL_MACHINE/SOFTWARE/Wow6432Node/Python/PythonCore
but there isn't anything that references any executables.
Any help appreciated!
You was on the right path. In your case, you would need to add the the following entries in the registry:
[HKEY_CURRENT_USER\SOFTWARE\Python\PythonCore\3.8]
[HKEY_CURRENT_USER\SOFTWARE\Python\PythonCore\3.8\InstallPath]
#="C:\\python38\\"
"ExecutablePath"="C:\\Python38\\python.exe"
"WindowedExecutablePath"="C:\\Python38\\pythonw.exe"
Also answered in py launcher does not find my Python 2.7

Atom script configure script run python 2.7

I have downloaded Anaconda on my computer however Anaconda is installed for all users on my mac therefore when I try and access python2.7 by typing in the path: /anaconda3/envs/py27/bin:/anaconda3/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
Even if I open from terminal the path above is not in the current directory since:
machintoshHD/anaconda3/....
machintoshHD/Users/adam/desktop....
how can i redirect the configure script feature in the atom package script so that i can run python 2?
Only way I can change Atom python is to run it from a directory that has a different default python version. if I type python from a terminal window, whichever version of python that opens is the version Atom uses. I use virtual environments so I can run python 2.7.13 or python 3.6. If I want Atom to run python 3, I activate my python 3 environment and then run atom.
There may be a way to do this from within Atom but I haven't found it yet.

Is it possible to easily extract python run configuration (with additional path) from Pycharm?

I have a working Python project on my PC, which I am running from Pycharm.
It uses Pyroot (an interface to Root C++ library), whose C++ lib path I have added in Project Settings/Python Interpreter/Paths in Pycharm. It also needs to use the 2.7 Python interpreter, instead of 3., which is a default python in my terminal.
I want to run this project remotely on another desktop, so I need to be able to run it from terminal specifying the path to Root and the interpreter version.
Is there a way to easily extract from Pycharm the exact run command it is using when I'm running the code via run button?
Alternatively, if that's impossible, how should I specify the path to Root and the interpreter version when running from terminal?
I guess to best way is to create a virtualenv either in the terminal or in pycharm including the corrext python version 2.7 and install pyroot via pip into this virtualenv. Then you can simply ssh in the remote host, activate the venv and start your project from the terminal. Or you ssh into it with X-forwarding and start Pycharm itself from your client.
If you select the correct project and go to File > Settings, under the Project Settings you can see the Project Interpreter which tells you which interpreter is being used.
Hope this is what you are looking for.

Issue with path to python/pythonpath

I have a VPS with system-wide installed python 2.5.
I installed python 2.7 to one of the user's home dir (using --prefix). added it to bashrc and bash_profile, exported python variable to env, and now when I type python in console python 2.7 is running.
But when I checked python version from my application (Django using with FastCGI) I still see that it is using 2.5.
In ps output I see python processes running for this account and apache processes runing with hosting-specific account. How can I switch this particular account to 2.7 without changing system-wide version?
Thanks!
One option is to use the python virtualenv tool to create a Python virtual environment that you can source in your .bashrc.
mike#tester:~$ virtualenv --python=/usr/bin/python3 $HOME/fcgi_python
Running virtualenv with interpreter /usr/bin/python3
Using base prefix '/usr'
New python executable in fcgi_python/bin/python3
Also creating executable in fcgi_python/bin/python
Installing Setuptools..............................................................................................................................................................................................................................done.
Installing Pip.....................................................................................................................................................................................................................................................................................................................................done.
mike#tester:~$ python --version
Python 2.7.5+
mike#tester:~$ source $HOME/fcgi_python/bin/activate
(fcgi_python)mike#tester:~$ python --version
Python 3.3.2+
In the example above you would replace the argument after --python= with the path to the Python interpreter installed in the user's home directory.
I had a call to python interpreter via env program in my fast cgi dispatch script. When I explicitly put path to 2.7 to the first line of the script it works as expected.
I've set PYTHONPATH in my /home/me/.bashrc and all worked ok from terminal, but when Apache w/ mod_wsgi starts my python scripts, it acts under sysem or dedicated user, which knows nothing of my .bashrc.
For this particular situation, I just used apache config (apache2.conf) to set python path for apache (WSGIPythonPath option).

Getting PyDev to recognize the correct Python Interpreter on Eclipse under OS X Lion

I have two versions of python installed on my mac running OSX Lion. The first is the default python version that ships with OSX and is found in /usr/bin/python. The version I want to use is the version I downloaded from python.org, and that is installed in /Library/Frameworks/Python.framework/Versions/2.7/bin/python. I want to use Eclipse and PyDev using the python.org version as the interpreter. So, in Eclipse, I go to preferences and set the version installed in /Library/Frameworks/Python.framework/Versions/2.7/bin/python to be the interpreter.
in a terminal window, if I type:
$ which python
I get "/Library/Frameworks/Python.framework/Versions/2.7/bin/python" because I set my $PATH accordingly (modified .bash_profile to permanently do so)
but if I run the following simple script in Eclipse:
import os
os.system("which python")
the script's output is "/usr/bin/python"
Things I have tried as suggested by other similar posts:
tried removing and re-adding the interpreter location
tried adding the /Library/.../package-sites to PYTHONPATH
Why isn't eclipse using the interpreter I explicitly tell it to use? Any help with this issue will be greatly appreciated!
The problem is that os.system('which python') will search for the python in the path, not the one where you're currently running (so, its output is correct).
What you want to use/check instead is sys.executable (this attribute will point to your currently running executable).
As for the wxPython issue, which error are you having? (probably another question in stackoverflow thought).
I think Eclipse is running the correct python. In your code when running under eclipse which python does not find the python running. Try
import sys
print sys.version
The issue here is that running a GUI app from the desktop/dock/folder does not load your .bash_profile and so which python does not find your change to the PATH. To change your path for GUI apps you need to edit ~/.MacOSX/environment.plist
I agree with Mark here. sys.version will be what eclipse uses to run your code. os.system("which python") will be python found in PATH that eclipse forwarded when running your code. Perhaps if you use PATH tweaks you should set environment variables for running code in Eclipse too.

Categories

Resources