I'm working in a multiuser environment with the following setup:
Linux 64bits environment (users can login in to different servers).
Eclipse (IBM Eclipse RSA-RTE) 32bits. So Java VM, Eclipse and PyDev is 32bits.
Python 3 interpreter is only available for 64bits at this moment.
In the preferences for PyDev, I want to set the path to the Python interpreter like this:
/app/python/#sys/3.2.2/bin/python
In Eclipse/PyDev, #sys points to i386_linux26 even if the system actually is amd64_linux26. So if I do not explicitly write amd64_linux26 instead of #sys, PyDev will not be able to find the Python 3 interpreter which is only available for 64bits. The link works as expected outside Eclipse/PyDev, e.g. in the terminal.
Any ideas how to force Eclipse/PyDev to use the real value of #sys?
Thanks in advance!
I don't really think there's anything that can be done on the PyDev side... it seems #sys is resolved based on the kind of process you're running (not your system), so, if you use a 64 bit vm (I think) it should work...
Other than that, you may have to provide the actual path instead of using #sys...
Related
I have used the regular IDLE python interpreter. Now I discovered PyCharm. It's a really good formatter and has a object hierarchy which I really like and auto-complete.
Unfortunately, PyCharm doesn't have the same interpreter as the regular python IDLE and I can't seem to get it to run w/ the regular python interpreter (Y'know, the one with the rocket in the icon?) and I can't seem to figure out how to get that same interpreter running
If you can give me any suggestions on how to get PyCharm to run on the regular interpreter, that would be nice, as I'm making a text based game, and the Pycharm console isn't great for those.
I've already tried looking into changing the pycharm interpreter (the rocketship python wasn't there) and the pycharm website didn't have exactly what i wanted
Basically, I want to only use PyCharm as a python formatter, and use the regular Python IDLE as a interpreter
Selecting Interpreter in Pycharm can be done by going to:
Settings -> Project -> Project interpreter
In the project interpreter dropdown, you can find interpreters you used in different Pycharm projects(if any).
If not then you can add them from the little + sign at the bottom go to the required new or existing environment and select the location of the base interpreter/ interpreter where you interpreter is saved in the file system.
As John Anderson's comment said, You can configure python interpreter by File->Settings->Progject->Project Interpreter, you said it didn't have you wanted so you must add interpreter by hand. click the setting button, and Add a python interpreter.Generally python interpreter located in C:\Users\\AppData\Local\Programs\python\python37\python.exe.
I am trying to use shutil.which to check if the Linux Subsystem is installed on Windows 10.
Using the Windows where command in Command Prompt, I can see the location of the wsl.exe executable.
C:\Users\spike>where wsl
C:\Windows\System32\wsl.exe
The above shows that WSL does exist, and is in my system PATH.
When I use the which function in Python, it says that the executable was not found.
print(which("wsl")) # Returns None
Just to make sure that which works, I test it on cmd.exe.
print(which("cmd")) # Returns "C:\Windows\System32\cmd.exe"
That works. Well, what if I make a system shell call with the command that did work?
print(system("where wsl")) # Returns 1
Exit code 1, the command wsl was not found.
So I test it on cmd.exe again.
print(system("where cmd")) # Returns 0
Okay, so that does work. What is the problem?
For each Python 3 example assume these imports.
from shutil import which
from os import system
Why can Python not find wsl.exe even though it is proven to exist?
Thanks.
Credit to #eryksun, who helped solve this in the comments.
The issue is that I am using 32 bit Python, and wsl.exe is only in C:/Windows/System32. The problem with this is that Python is looking in C:/Windows/SysWOW64 for the executable instead.
wsl.exe is only 64-bit, and you're looking in SysWOW64 instead of the real System32 because you're using 32-bit Python. – eryksun
Because WSL only supports 64-bit systems, I ended up just running my code with 64-bit Python. However, and alternate solution if you only use Py32 would be to access SysWOW64 directly, using the system root environment variable and os.path.join.
In Windows 7+, the real System32 directory is accessible in a 32-bit process as "SysNative". Unfortunately this virtual directory isn't available in a native 64-bit process, so you need to first check whether it exists. For example: sysnative = os.path.join(os.environ['SystemRoot'], 'SysNative'); if os.path.exists(sysnative): .... – eryksun
Now you can install python in 64 bit and everything will work just fine. (Be careful that when the python installer runs, there should be written 64 bit packages and other things as 64 bits [right where the loading bar is])
I am running OS X Lion, Python 2.7, and I am trying to setup Pygame to work with PyDev in Eclipse. I set up PyDev to use a custom-installed Python (not the default one). I forced this install to use 32-bit, which works fine in the Terminal - I can import Pygame, and other modules. However, when I use it in PyDev, it gives me a no matching architecture error. It also appears to be running in 64-bit mode.
The paths to the interpreter are the same.
import sys
print ("%x" % sys.maxsize, sys.maxsize > 2**32)
prints out ('7fffffff', False) while using Terminal, but in Eclipse/PyDev it prints out ('7fffffffffffffff', True)
The two paths (using sys.executable) are:
In Terminal it is:
/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
And in Eclipse it is
/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
The path to the interpreter I used is: /Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7
I also tried manually specifying the interpreter in Terminal - Using the above path. It worked.
The default python that comes with the system is /usr/bin/python
I am using a 32-bit version of Eclipse classic as shown by an answer to this question.
Does anyone have any idea what is wrong?
You need to instruct eclipse to use 32-bit python.
Right-click on your project -> properties -> PyDen/Interpreter grammar and select "Click here to configure an interpreter not listed"
After you add your new python binary (e.g. C:\Python27\python.exe), you go back to the interpreter menu in the properties window and you select this interpreter from the corresponding drop-down menu.
I solved this by using a method describe in an answer to another question.
The answer said to go to your plugins/org.python.pydev/pysrc and open interpreterInfo.py. Then you replace all the instances of sys.executable with the path to the interpreter you want.
In my case, this meant changing them to /Library/Frameworks/Python.framework/Version/2.7/bin/python2.7
After that, open up eclipse and create a new interpreter with the same path, and it should work.
Questions similar to this one have been asked but I haven't seen a solution yet that helps me.
I am running Windows 7 and I've installed two versions of python, 3.3 and 2.7. Python 3.3 was the first version I installed and I was able to run scripts from the desktop (not the command line). I installed python 2.7 so that I could get numpy, scipy, and matplotlib down the road, but I found that all the scripts on my desktop defaulted to python 2.7. Since I coded in 3.3 this caused some issues.
I was able to fix this by right clicking the script icon, browsing programs, navigating to the python 3.3 file in my C: drive, and selecting the idle inside that directory. But then I found I wasn't able to run those scripts with python 2.7 using the exact same procedure.
Unfortunately I don't know command-line programming very much at all, and it seemed like most of the answers were geared towards that as a solution. Ideally I'd like to specify which python I want to run a script from the desktop, or possibly while I'm editing the script.
If it's relevant I'm running the eric python IDE, version 5.
I'd be happy to do the work of reading something fairly technical and long (like a blog post or PDF), but it won't help me much if it isn't aimed at beginners.
The Windows Python Launcher can automatically detect the Python from the shebang in your file.
Start your Python 3.3 scripts with
#!/usr/bin/env python3
and your Python 2.7 scripts with
#!/usr/bin/env python2.7
If you want to use the system's default Python version, you can just start the file with
#!/usr/bin/env python
This will also work on virtually all Unix systems.
Maybe you should chose another IDE, like PyCharm, it could manage different versions of python easily (and gives tons of other useful features). Perhaps free PyDev could also make it.
Also, using virtualenv — is the best solution here, but it's a "hard way".
The method I use is to have several cmd.exe shortcuts on my desktop, each pointing at a different runpython.bat file, one for each version of python. Here is one command example from a shortcut:
%comspec% /k "C:\QA\Python\QAPYTH3\runpython.bat"
Here is a typical runpython.bat:
#SET PATH=%PATH%;"C:\Python32"
#SET PYTHONPATH=C:\Python32\Lib
#ASSOC .py=Python.File
#ASSOC .pyc=Python.CompiledFile
#ASSOC .pyo=Python.CompiledFile
#ASSOC .pyw=Python.NoConFile
#FTYPE Python.CompiledFile="C:\Python32\python.exe" "%%1" %%*
#FTYPE Python.File="C:\Python32\python.exe" "%%1" %%*
#FTYPE Python.NoConFile="C:\Python32\pythonw.exe" "%%1" %%*
#SET PATHEXT=.py;%PATHEXT%
Of course you don't have to call your .bat files the same as I have. Just adjust to suite your setup.
I configured my Emacs for code completion and other help using this link (from another question here on SO). I am a complete newbie to emacs.
Can anyone tell me what should I change so it (rope, ropemacs, pymacs, yasnippet etc) picks up symbols of IronPython modules for code completion and snippets.
Also I want to map:
C-x RET - to invoke IronPython.exe and not Python.exe (any clue on how to do that)
PS I am using Emacs with Cygwin on XP machine
The variable python-command contains the path of the python interpreter to be run. By default, this is usually just set to "python", which runs the first python in your path.
Try changing it to point directly to the IronPython exe file:
(setq python-command "C:/Program Files/IronPython 2.6/ipy.exe")