Python on Windows error: python25.dll not found - python

I am running Python 2.7 on Windows 7 (on parallels on a Mac running Mountain Lion) and getting a strange error. It has happened both using Python(x,y) and the Enthought Python Distribution (paid version - 64-bit).
Running python from the command line initially works fine (and always does after rebooting the machine).
But, when I try to run my code at the command line as
python the_script.py
On the first try, I get this error window:
After that, I get the same error just from typing python at the command line.
If I specify the path as c:\python27\python the_script.py it works fine.
Here are all the modules I'm loading in my scripts:
import numpy as np
import subprocess as sub
import parallel_condor_Jacobian as pcj
import os
import shutil
In parallel_condor_Jacobian the following modules are loaded:
import numpy as np
import os
import subprocess as sub
Nothing really out of the ordinary I think!
Is one of these packages somehow dependent on python25.dll?
Fixes I have tried include totally removing python 2.7, reinstalling, and removing all python path stuff from my PATH environment variable and replacing them with c:\python27.
I'm really at a loss here. Happy to provide more relevant information.

remove the python.exe in the local folder ... and tell your colleagues to upgrade to at least 2.6 :P
and also tell them that the python exe is not portable :P

Related

VSCode - import errors and interpreter errors

I have several imports in my current code:
from flask import Flask
import datetime as dt
import numpy as np
import pandas as pd
When I run this in VSCODE I am getting this error:
However, running this in jupyter notebook has no problems. When I looked online it said to use python interpreter but when I go to do that I get this error:
And another error:
Anaconda prompt says modules/packages are installed but when I run pip install in default windows terminal it says pip has no module:
Delete and reinstall Python extensions according to the same problem on github.
The second problem is related to the location of your Python interpreter. You need to choose the correct interpreter. I still recommend using one Python version in one environment. You can use other Python versions in virtual environment, so it won't lead to confusion.

Importing a module works in IDE but doesn't work in windows command line (edited)

I am new to Python so this may be a stupid question, sorry in advance if it is so!
The paths Python searches for modules using Spyder 4.1.4.:
[.., 'D:\Users\Martin\Anaconda3\lib\site-packages', ..]
The paths Python searches for when used via command line in windows:
[.., 'D:\Users\Martin\Anaconda3\lib\site-packages', ..]
Thus, both include path to
'D:\Users\Martin\Anaconda3\lib\site-packages'
where I store my cv2 module installed. Yet, Spyder can import cv2 and to my surprise cmd cannot import cv2 with an error No module named 'cv2'. What am I missing please? Can anyone verify if it works for him in command line please? (I changed/edited the question again to cut unneccessary long talk, though the essence stayed the same, in hope someone could answer).
I solved it. If you have a similar problem, you can check if your case is similar to mine and follow the steps.
I use Spyder and everything works fine. However my goal is to use Python via cmd. This could not be done because Python via cmd could not find my modules.
What I did: After typing python in cmd, Python worked and output its version by default. However, I noticed the version was different than version running in Spyder - I had two Python installations (one of which I didn't know about). I found the installation cmd uses by import sys and print(sys.executable). I uninstalled that Python installation.
Now, typing python in cmd does not do anything, it is an unknown command. Then I followed this guide to add my Python installation to Path (using Windows) by:
My Computer > Properties > Advanced System Settings > Environment Variables >
in System variables, I found "Path", clicked Edit, New, then input my Python installation path D:\Users\Martin\Anaconda3 as well as D:\Users\Martin\Anaconda3\Scripts and D:\Users\Martin\Anaconda3\Library\bin. This solved it for me.

So i installed numpy . But when i call it in a program an error occurs. Any method to solve it permanently in windows 10

Here is the error
import numpy
Exception has occurred: ModuleNotFoundError
No module named 'numpy'
File "C:\path\to\file\32.py", line 1, in <module>
import numpy
Let me know how did you install the NumPy package; using pip or something else?
If you have multiple python versions, i.e. 2.x and 3.x at the same time, please make sure your interpreter for the 32.py file is the version that you installed NumPy on.
To possibly fix your problem, you should first try installing it and see if there are any errors. You should also check the version of Python you are running on Windows 10, because when you update Python it sometimes switches names between py and python
As you can see, the version of Python has changed between py and python so you should try changing that first.
If this does not work, you should try finding the directory for NumPy and adding it to the system PATH in your script. The installer usually shows you the location by doing the following:
import sys
sys.path.append("<insert numpy location here>")
import NumPy
This should manually force it into finding the package. If none of this works, please tell us and we should be able to find a different solution.
Happy Coding!
If you're using a code editor like PyCharm, you could install it by clicking on
file then settings then the project interpreter setting and install new module! You can search for the module and install.
Make sure that the python version that you want to use is a Windows Environmental Variable. You can test this by running this line in your command line.
> python --version
If you get some other python version that is not the one that you wish to use you can set the python version you want by finding where exactly your Python folder is located and go into settings and set the path as a new variable (I can leave a tutorial for you). If that is too much of a hassle, the Python installers can set the python that you will install as an environmental variable for you. (You could uninstall and reinstall and make sure that you allow it to make it an environmental variable.
After that you should be able to import whatever external packages you want using pip
for example:
pip install numpy

cv2 and opencv Python troubleshooting install

I'm totally new to python. Currently I'm trying to install a packaged named cv2/openvc. Having migrated from Rstudio I'm trying to use rodeo in the same way for python. Python definitely seems less user friendly.
When I try to import the package from rodeo and I get following error:
However, when I run python from the windows cmd line and all works fine, I can even import cv2 and check the version.
Why is this and how can I fix it?
I can say the best thing you can do is to really know which python installation is being used by Rodeo. However, if you are in hurry you can install cv2 within the python interpreter by this code:
import sys
import subprocess
subprocess.call([sys.executable, "-m", "pip", "install", "opencv-python"])

Packages not working, using Anaconda

I have installed Anaconda for Windows. It's on my work PC, so I chose the option "Just for Me" as I don't have admin rights.
Anaconda is installed on the following directory:
c:\Users\huf069\AppData\Local\Continuum\Anaconda
The Windows installer has added this directory (+ the Anaconda\Scripts directory) to the System path.
I can launch Python but trying to run
x = randn(100,100)
gives me a Name Error: name 'randn' is not defined,
whereas, as I understood, this command should work when using Anaconda, as the numpy package is included.
it works fine if I do:
import numpy
numpy.random.randn(100,100)
Anyone understand what could be happening ?
I can launch Python, but trying to run x = randn(100,100) gives me a Name Error: name 'randn' is not defined, whereas, as I understood, this command should work when using Anaconda, as the numpy package is included
The Anaconda distribution comes with the numpy package included, but still you'll need to import the package. If you want to use the randn() function without having to call the complete name, you can import it to your local namespace:
from numpy.random import randn
x = randn(100,100)
Otherwise, the call numpy.random.randn is your way to go.
You might want tot take a look at the Modules section of the Python Tutorial.

Categories

Resources