Today I tried to create a new python project unsing Pycharm, with Python3.2. But I figured out that something is wrong.
When I tried to find the path of my python interpreter, I get that one:
Python 3.2 (r32, Apr 18 2018)
>>> import sys
>>> print(sys.executable)
/usr/local/bin/python3.2
So I put this path on the filling section Base interpreter.
Windows python interpreter Pycharm Project
But when pressing button Create project, this error occurs:
Traceback (most recent call last):
File "/home/David/pycharm-community-2018.1.1/helpers/packaging_tool.py", line 159, in main
retcode = do_untar(name)
File "/home/David/pycharm-community-2018.1.1/helpers/packaging_tool.py", line 100, in do_untar
tar = tarfile.open(name)
File "/usr/local/lib/python3.2/tarfile.py", line 1744, in open
raise ReadError("file could not be opened successfully")
tarfile.ReadError: file could not be opened successfully
Could someone tell me what is wrong? Thanks.
I've got stuck with exactly the same thing and found the answer here:
https://intellij-support.jetbrains.com/hc/en-us/community/posts/206601205-Can-t-Install-setuptools-from-within-PyCharm-on-Linux?page=1
You have to compile zlib and recompile python with zlib headers path.
Here's how to compile Python (don't forget the -with-zlib part):
https://stackabuse.com/install-python-on-mac-osx/#installpythonfromsource
Related
I'm trying to make an executable file for a project so my friends don't need to install python, using pyinstaller
When using pyinstaller with "-w"
The executable shows an Attribute error
Traceback (most recent call last):
File "main.py", line 7, in <module>
display = calendar_object.make_calendar()
AttributeError: 'Calendar' object has no attribute 'make_calendar'
but when I open main.py in the terminal it is completely fine.
When using pyinstaller without "-w"
It opens and closes immediately, and yes I have a while loop and an input inside so I'm guessing there's again, something wrong with my file
Temporary Solution:
Inserting all the separate files into one file.
Code Sample:
main.py
calendar.py
You seem to be using a name for your class that is mimicking the python internal calendar class.
Rename your class and you should be fine
I have this Python code: https://github.com/andreagrandi/aoc_2019/tree/master/aoc
which runs perfectly from the terminal (Python 3 required) if I do for example: python aoc_03.py
But if I try to run it from VSCode, taking advantage of the Python extension and integration, I get this error:
(aoc) ➜ advent_of_code_2019 git:(master) /Users/andrea/.virtualenvs/aoc/bin/python /Users/andrea/Documents/advent_of_code_2019/aoc/aoc_03.py
Traceback (most recent call last):
File "/Users/andrea/Documents/advent_of_code_2019/aoc/aoc_03.py", line 70, in <module>
with open('aoc_03_input.txt', 'r') as file:
FileNotFoundError: [Errno 2] No such file or directory: 'aoc_03_input.txt'
My guess is that when invoked from VSCode, the script is run from a different path, so it cannot find the file aoc_03_input.txt which is located in the same folder of the script.
How do I tell VSCode to run my script from the /Users/andrea/Documents/advent_of_code_2019/aoc/ folder, so that it will be able to find my input file?
Thanks
Actually, I should have tried more before asking this question, because I just found the solution, but at this point I will write it here in case it can be useful to anyone:
If I change the path in this way:
with open('./aoc_03_input.txt', 'r') as file:
The file is being open correctly when I run the code in VSCode and when I run it from the terminal. Tested under OSX (but it should work under Linux too. Not sure about Windows).
I just moved from sublime to eclipse and ran a program which contained the time library 'Arrow'.
It first said the no module could be found, so I then I added the source folder to the PyDev python path, now it's giving me this error:
Traceback (most recent call last):
File "C:\Users\David\workspace\Loan_rates\master.py", line 8, in <module>
import arrow
File "C:\Python27\Lib\site-packages\arrow\arrow.py", line 16, in <module>
from arrow import util, locales, parser, formatter
ImportError: cannot import name util
I think the problem is that you added:
C:\Python27\Lib\site-packages\arrow to your Interpreter PYTHONPATH -- which makes it resolve C:\Python27\Lib\site-packages\arrow\arrow.py as the arrow module.
The solution is removing C:\Python27\Lib\site-packages\arrow from the PYTHONPATH -- C:\Python27\Lib\site-packages should be enough in this case.
Try comparing the command line that works (when launched successfully from your terminal) to what PyDev is constructing.
To see the command line PyDev actually uses, open the launch configuration (Run menu -> Run Configurations... -> Python run -> Select your launch on the left) and in the Interpreter tab press See resulting command-line for the given parameters.
This is a screenshot of what I am referring to:
I am trying to use vdebug with MacVim and xdebug to debug code. I have MacVim and python installed via homebrew and xdebug is installed and working fine with MacGDBp.
When I listen in vdebug with the F5 key and reload a page (xdebug remote autostart is on) I get a python error in the vdebug quickfix window:
An error occured: <type 'exceptions.ImportError'>
Traceback (most recent call last):
File "/Users/mikedfunk/dotfiles/.vim/bundle/vdebug/plugin/python/start_vdebug.py", line 31, in run
self.runner.run()
File "/Users/mikedfunk/dotfiles/.vim/bundle/vdebug/plugin/python/vdebug/runner.py", line 160, in run
self.open()
File "/Users/mikedfunk/dotfiles/.vim/bundle/vdebug/plugin/python/vdebug/runner.py", line 74, in open
raise e
ImportError: No module named expat; use SimpleXMLTreeBuilder instead
I've googled this for a while and can't find a working solution. Any ideas?
This worked for me! Posted in case anyone else has the same problem:
https://stackoverflow.com/a/12697440/557215
It temporarily links the homebrew version of python to the mac system version before reinstalling MacVim. Now xdebug works!
So I am having trouble compiling a very simple python script using JPype.
My code goes like:
from jpype import *
startJVM(getDefaultJVMPath(), "-ea")
java.lang.System.out.println("hello world")
shutdownJVM()
and when I run it I receive an error saying:
Traceback (most recent call last): File "test.py", line 2, in
<module>
startJVM(getDefaultJVMPath(), "-ea") File "/usr/lib/pymodules/python2.7/jpype/_core.py", line 44, in startJVM
_jpype.startup(jvm, tuple(args), True) RuntimeError: Unable to load DLL [/usr/java/jre1.5.0_05/lib/i386/client/libjvm.so], error =
/usr/java/jre1.5.0_05/lib/i386/client/libjvm.so: cannot open shared
object file: No such file or directory at
src/native/common/include/jp_platform_linux.h:45
I'm stuck and I really need help. Thanks!
I had the same problem
RuntimeError: Unable to load DLL [/usr/java/jre1.5.0_05/lib/i386/client/libjvm.so], error = /usr/java/jre1.5.0_05/lib/i386/client/libjvm.so: cannot open shared object file: No such file or directory at src/native/common/include/jp_platform_linux.h:45
In my case wrong JAVA_HOME path was set
/profile/etc
export JAVA_HOME
JAVA_HOME=/usr/lib/jvm/java-6-openjdk-amd64
PATH="$JAVA_HOME/bin:$PATH"
export PATH
The work around is to define the full path directly in the call to the JVM:
from jpype import *
startJVM('/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/MacOS/libjli.dylib', "-ea", "-Djava.class.path=/tmp/Jpype/sample")
java.lang.System.out.println("Hello World!!")
shutdownJVM()
Original text:
Similar issues when trying to run JPype on MacOS El Capitan. I could
not figure out how to coax the _darwin.py code finding the correct JVM
location, despite the JAVA_HOME system variable being set properly.
Caveat cursor, trying to run the above code in the Spyder IPython console did not produce any output, but the normal Console would.