Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
The community reviewed whether to reopen this question 8 months ago and left it closed:
Original close reason(s) were not resolved
Improve this question
I started to learn python language, and decided to try out PyCharm IDE, which looks really nice. But, whenever I write print it says "Unresolved reference 'print'". I can run the program, but this red-underline is really annoying. How can I fix this?
I have had the same problem as you, even though I configured Python 3.4.0 as the project's interpreter and all print's in the code were Python 3 compliant function calls.
I got it sorted out by doing this in PyCharm:
File -> Invalidate Caches / Restart... -> Invalidate and Restart
If you're in PyCharm and you're getting "Unresolved reference xrange" it's because xrange was removed in Python 3. Range takes over its functionality now. Was working on fast string concat from here:
https://waymoot.org/home/python_string/
And credit for the answer is from /r/learnpython:
https://www.reddit.com/r/learnpython/comments/2udj3s/pycharm_issue/
This could be related to the version of python you are using. Under python 2.x print is a statement:
print "hello world"
Under python 3, print is now a function call:
print("hello world")
Same problem, I deleted the .idea and __pycache__ directories in the project directory and everything was fine :)
Just delete .idea folder from your project directory.
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
TEMPORAL WORKAROUND: https://www.reddit.com/r/vscode/comments/i45agt/cannot_type_code_into_python_interactive_console/
EDIT: this is a bug in new version of VSCode. There are also a few issues raised on github with the same problem. I will leave the question here, despite that it still gets minus points and got closed twice, as I was not able to find out any answer by googling, maybe it will help someone.
... Asking the same question once again, could you please tell me what details shall I add or how to specify the problem in better way, before you close it again in 10 minutes? I am desperate, can not work and have no one to ask, there is nothing on google with this issue....
So I am using VSCode and an interactive environment. By now everything worked just fine and I am not aware that something changed (I have not installed anything new, nor updated anything, so it might have been done somewhere in the background). Now the problem arises: I am able to run interactive, but only from the script with using cells #%% , however, the interactive window does not allow me to write anything into it directly into Type code here and press shift-enter to run. What is even more strange, yesterday it allowed me to write into this window some code and execute it and then suddenly it stopped working and I had to write code into the script again...
I am using VSCode Version: 1.51.1 and python 3.7.4 64-bit.
I have the same issue - it seems to be a bug in VScode. The only thing that works is simply to close it and open it again, until they fix it - anoying as it is
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
Before you get confused, I am going to compile it with the auto-py-to-exe module after, its just the source code is in python. How do I do this?
If Python is not installed you wouldn't even be able to run a script to check if it's installed.
I'm pretty sure there isn't from inside the Python script. Because the interpreter isn't installed, so it'll never be able to understand HOW to execute the script at all.
You'll have to check outside in whatever is initiating the Python script and the compilation (bash script?) and do it there.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
I've searched the Google and on stackoverflow for this, so if it exists anywhere, my sincerest apologies. I'm (obviously) a newbie to Python, and one of my main concern with finding a new module that does whatever new programming project comes my way is this:
What's preventing a module (once imported) from doing nefarious things, such as logging all keystrokes while the script is executing, then emailing that out?
Am I being paranoid?
Is this not possible in Python?
Is there a website where modules have been code reviewed, and people can download / install them without needing to worry?
Do I have to read the code of every module / sub-module every time I download it to ensure this exact thing isn't happening?
I'm currently using Python 3.5.1 64-bit on Windows 8, but I doubt that's too relevant.
Nothing prevents it. That's one of the benefits of open-source software (in the strictest sense of "source code that I can view"): you can, in theory, examine it to see exactly what it does before actually running it.
In practice, you usually just extend some level of trust to the source:
Is the module in wide use, such that others would have discovered or mentioned a problem in the first place?
Did I get the module from a reputable source?
Does the checksum of my copy match the checksum provided by my source?
If the answer to all three is yes, you can assume that the module isn't doing anything shady without explicitly verifying it yourself.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I'm writing a script in Python, but when I attempt to run it a cross cursor appears and lets me take screenshots. But that's not part of my program, and the rest of the script never executes at all!
The minimal code that produces this behavior is:
import fiona
import scipy
It's a known issue which regularly happens to some.
Without a python shebang line the script is treated as a shell script. And line import module is treated as a command to run import application, which is present on your system (part of ImageMagick, I guess) and makes a screenshot saving it to the specified file.
It got solved by adding the shebang:
#!/usr/bin/env python
but I really don't understand why...
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I've just started learning Python, and I'm pretty lost right now. I want to run my script on my server that is hosted through hosting24.com. Their FAQ says they support Python, but I have no clue where to put my script for it to run.
There is a folder called cgi-bin in my root, I'm guessing that is where I put my script? Can someone explain to me how this works?
Very simply, you can rename your Python script to "pythonscript.cgi".
Post that in your cgi-bin directory, add the appropriate permissions and browse to it.
This is a great link you can start with.
Here's another good one.
Hope that helps.
EDIT (09/12/2015): The second link has long been removed. Replaced it with one that provides information referenced from the original.