I am using python 2.7.5 on windows and I have followed these directions for the windows python 2 section to the letter.
I found 2 other questions on SO with the same problem but they were both on linux and the top answers were not helpful
the only thing I can see that might have gone wrong is when I ran
C:\env> scripts\easy_install pyramid
I got a warning that said :
"WARNING: The C extension could not be complied, speedups are not enabled. Plain-Python installation succeeded."
Could that be the problem?
I found the answer to my problem. My virtual environment was correctly set up, I just needed to run my code through the version of python found in the scripts folder of my virtual environment.
The python file you are trying to run can be found anywhere on your local machine as long as it uses python from that environment, for example
C:\anypath\onlocalmachine> C:\env\Scripts\python.exe helloworld.py
I was making the mistake of putting my python file in the virtual environment and attempting to run the following WRONG code
C:\env> helloworld.py
I thought that I was supposed to be working entirely within the virtual environment
Thanks for the help in the comments rebelious
Related
I am trying to learn Python and debug code for the first time in VS Code (latest edition). I have anaconda running and the code I have runs fine by itself but now I need to know how to update the code and debug it for the first time.
I keep getting the following error related to NumPy:
Exception has occurred: ImportError
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.
We have compiled some common reasons and troubleshooting tips at:
https://numpy.org/devdocs/user/troubleshooting-importerror.html
Please note and check the following:
The Python version is: Python3.7 from "C:\Miniconda2\envs\myproject_flask\python.exe"
The NumPy version is: "1.18.5"
and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.
Original error was: DLL load failed: The specified module could not be found.
In the Miniconda path above the Python.exe is version 3.7.7. I tried to install NumPy like so in myproject directory:
(myproject_flask) c:\MyProject\source\MyProject.Flask>conda install numpy=1.18.5
I still get the same error when I go to F5 to debug and run to a breakpoint.
Need help with my environment.
I need to use VS Code in my Windows environment with Anaconda.
You should launch VS Code from Anaconda Navigator so that the environment is initialized.
When you have problems with importing the numpy C-extensions in Anaconda it's very likely that your virtual environment hasn't been activated. Having just Python on the path is not good enough. You also need access to the libraries. This is what the activation does.
When you are running/debugging code you should see a terminal open. You can tell from the prompt
(myproject_flask) C:\MyProject
that conda has been activated. Sometimes this just takes a bit too long for VSCode. So simply push the start button a second time.
Note that the Code Runner extension in VSCode is also known to cause this kind of problems.
However, I wonder why you are using Miniconda2 with Python3, although in general this should work.
I was getting the error even after adding all the anaconda paths, it was due to VScode running the code in the python debugger terminal which is not able to enter the conda environment.
This worked for me:
press ctrl+Shift+P > Type Terminal:Select Default profile > Select Command prompt
after this code ran in Command prompt by default, inside the environment.
Currently on windows 10, using VSCode to run python.
So I recently downloaded python3.8 when I was using python 3.7. Everything was working fine when I was still on python3.7. I now have multiple python directories and I think my imported libraries are throwing errors because of it.
I now have python in(these are results from searching python and right clicking -> open file location) :
C:\Python38
C:\Users\david\AppData\Roaming\Python\Python38
C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Python 3.8
C:\Users\david\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Python 3.7
As for installed programs I have :
python3.8.5(64-bit)
Python launcher
Should I add all four paths to my environment...?
Frankly I don't even know anymore how to tackle this problem. I'm not even sure what the problem is I just think its a problem. If someone could link me another stackoverflow or help that would be great.
If this isn't supposed to be a problem then I guess I have some more googling to do...
Thank you
EDIT(commented below): One specific error I keep on getting is when I install keras and tensorflow, and run a program, it keeps on asking me to install tensorflow 2.2.0 even though I've already installed it. I have C:\Python38 and C:\Users\david\AppData\Roaming\Python\Python38 in my windows path and C:\Python38 as my VSCode path –
I'm a complete beginner to coding, Python, and anything beyond user-level computing. I've been learning to code with Python and everything was fine until I tried to import a module outside of Python's Standard Library (pyglet).
pip install pyglet worked and now returns:
> Requirement already satisfied: pyglet in
c:\users\nick\appdata\local\programs\python\python38-32 (1.5.7)
Then I received an error message when running the module in PyCharm.
>C:\Users\Nick\venv\Scripts\python.exe C:/Users/Nick/PycharmProjects/learning1/leaning1.GUI.py
Traceback (most recent call last):
File "C:/Users/Nick/PycharmProjects/learning1/leaning1.GUI.py", line 1, in <module>
import pyglet
ModuleNotFoundError: No module named 'pyglet'
Process finished with exit code 1
I think there are a few possible sources for the issue.
I think I might be saving files in multiple directories, so PyCharm is unable to find what I need. If that's the problem please direct me to a resource on learning how to organize files on my computer (something very basic about directories because I know nothing).
I installed python via python.org, but then Microsoft Store was being opened automatically when I tried to check my python version in the command line. I also downloaded Python from Windows Store.
I tried to solve my problems by completely uninstalling PyCharm, Python (windows store), and Python (python.org). I also tried to delete all previous .py files. I don't think I located everything.
I messed with the interpreter settings in PyCharm.
What I really want is to just start over from a clean slate by scrubbing all Python things!
There are a few steps you should take to prevent this sort of issue:
Use a virtual environment: steps to create a virtual environment
Verify that PyCharm's project interpreter is the virtual environment you just created (in my example, the project is named cheetah and the virtual environment is also named cheetah):
I recently updated to Anaconda to 2.1. For some reason, Pycharm 3.4 was previously configured with E.Canopy - Python 2.7.6. I did not know that, so yesterday I uninstalled Canopy. Now when I open PyCharm I get:
Invalid Python interpreter selected for the project
So I followed the instructions to configure the appropriate interpreter: Anaconda. However the configuration fails. I get:
11:44:38 AM Some skeletons failed to generate: 1 module failed in 1 interpreter. Details...
Failed Modules
**Python 2.7.7**
dde
Generation of skeletons for the modules above will be tried again when modules are updated or a
new version of generator is available
So it seems there's a conflict because of the different Python Versions....How can I solve this?
Thanks
That happend to me... I just repeated the update process. hope this helps.
I'm trying to follow this tutorial and I'm getting the following error:
ImportError: No module named django.core.management
I'm completely new to python. I believe Visual studio is using a version of python I already had installed in c:\Python27, could that be causing a problem?
Someone mentioned in a link I found that they had to copy the 'django' folder to the project folder, but I don't know where that would be. I don't even know what the error means really unless there's a missing package (like dll or assembly in .NET?), but I don't know what paths python would use to try to find a package or even what one would look like.
I see there's a PYTHONPATH environment variable that I don't have declared, should I declare that? Should it point to the C:\Python27 directory?
First, do you have checked your "Python Environment" in your project folder? It may seems like...
Here you may find your django with version. If you dont find it then compile setup.py from django folder again with desire python version. And then right click on "Python Environments" from your project and click on "Add/Remove Python Environments" to select python version.
Ok with a lot of fooling around I found this directory:
%LOCALAPPDATA%\Microsoft\Web Platform Installer\installers\PythonDetectInstalls
In a mangled sub-folder there is a powershell script DetectPythonInistalls.ps1 that has these two lines for checking if python is installed already:
$regKey = "hklm:SOFTWARE\Python\PythonCore\$pythonVersion\InstallPath";
$correctRegKey = "hklm:SOFTWARE\Wow6432Node\Python\PythonCore\$pythonVersion\InstallPath";
Uninstalling all my pythons did not remove these keys. After removing these registry keys with regedit, WPI allowed me to install its own version of python 2.7 and all the other goodies to go with the Windows Azure Python SDK and it worked.