0

I recently had my work computer changed due to IT policy and had to reinstall my Python environment. My work computer is Policy controlled so I cannot install Python from the official Python.org installers, rather I have to install Python from the packages in my company's software repository, and they don't allow Python 3.12.

The Python installation went off without a hitch, and my Python interpreter is installed in C:/Users/609049066/AppData/Local/Microsoft/WindowsApps/python3.11.exe. For running my code I had written in a previous machine, I needed pandas, so I used command pip install pandas to install the package. The package installation also went off without a hitch. The packages were installed in C:\Users\609049066\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages.

In my code, the first line is import pandas as pd. As soon as the Python interpreter executes this, I get the below error and my code execution stops.

Traceback (most recent call last):
  File "c:\Soumik Work\Code\GenesysCloudRoutingObjectsToolkit\get_All_Divisions_v1.py", line 2, in <module>
    import pandas as pd
  File "C:\Users\609049066\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\pandas\__init__.py", line 32, in <module>
    raise ImportError(
ImportError: Unable to import required dependencies:
numpy: Error importing numpy: you should not try to import numpy from
        its source directory; please exit the numpy source tree, and relaunch
        your python interpreter from there.

Soumik

I have been looking at other forum posts and none of them help. I have the constraint that I cannot install Python 3.12.4 from Python.org as this is restricted on my work computer. I have added the location of the Scripts folder (C:\Users\609049066\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\Scripts) in the Windows Environment variables and rebooted my machine to no avail.

On my previous computer, the exact same code used to run fine with zero errors. My previous work computer used Python 3.10 and was Windows 10, whereas my new machine is Windows 11. I have tried uninstalling Python 3.11 as well as pandas package, installing Python 3.10 on my new machine and trying with the pandas package, but the error persists.

Can anyone suggest what am I doing wrong?

Soumik

3
  • You might try running the script from a folder in C:\Users instead of from C:\Soumik Work, as the different locations seem to be impacting your ability to import numpy (hence, "relaunch your interpreter from there".) Commented Jun 24, 2024 at 14:05
  • @AmericanJael, I tried that, and the same result persists. I feel this is not related to the location of the Python script itself, but rather some new way the pandas package and its numpy dependency must be called. Anyone has any further idea? Commented Jun 25, 2024 at 11:06
  • Have you tried creating a virtual environment (docs.python.org/3/library/venv.html) in your project root, install your dependencies in there and use this to launch the project? Commented Jun 26, 2024 at 6:55

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.